久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Google Drive Android API - 無(wú)效的 DriveId 和 Null Resourc

Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無(wú)效的 DriveId 和 Null ResourceId)
本文介紹了Google Drive Android API - 無(wú)效的 DriveId 和 Null ResourceId的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我整天都在與這段代碼作斗爭(zhēng),但沒(méi)有運(yùn)氣.我從以下代碼開(kāi)始 示例來(lái)自 Google.

I have been battling this code the whole day without luck. I started by following this code sample from Google.

問(wèn)題是該文件夾已成功創(chuàng)建,但在 onResult() 內(nèi),我總是得到一個(gè)無(wú)效或不完整的 DriveId 或 resourceId.這意味著我無(wú)法在我創(chuàng)建的文件夾中創(chuàng)建文件.這是我正在使用的代碼:

The problem is that the folder gets created successfully but inside onResult(), I always get a DriveId or resourceId that is invalid or incomplete. That means I cannot create a file inside the folder I created. Here is the code I am using:

public class CreateFolderActivity extends BaseDemoActivity {

@Override
public void onConnected(Bundle connectionHint) {
    super.onConnected(connectionHint);
    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
            .setTitle("MyAppFolder").build();
    Drive.DriveApi.getRootFolder(getGoogleApiClient()).createFolder(
            getGoogleApiClient(), changeSet).setResultCallback(callback);
}

final ResultCallback<DriveFolderResult> callback = new ResultCallback<DriveFolderResult>() {
    @Override
    public void onResult(DriveFolderResult result) {
        if (!result.getStatus().isSuccess()) {
            showMessage("Error while trying to create the folder");
            return;
        }

        // this value is always invalid with ending == operators
        Log.d("DRIVEID", "Created a folder: " + result.getDriveFolder().getDriveId());
    }
  };
}

每當(dāng)我運(yùn)行此代碼時(shí),我都會(huì)得到以下看起來(lái)不完整的 id:

Whenever I run this code, I get the following id which appears incomplete:

CAESABi2VyCCzdWOuVMoAQ==

我不知道這里發(fā)生了什么!

I don't know what is happening here!

我在 Google 上搜索并閱讀了添加偵聽(tīng)器以偵聽(tīng)完成事件,但它們似乎都不起作用.

I have Google'd around and read of adding listeners to listen for completion events but none of them seem to work.

我在 SO 上看到了幾乎類似的問(wèn)題,但沒(méi)有一個(gè)對(duì)我有用.

I have seen nearly similar questions on SO on this but none of them work for me.

我在應(yīng)用創(chuàng)建后通過(guò)瀏覽器手動(dòng)復(fù)制了 FolderId,然后粘貼到我的 android 代碼中,應(yīng)用成功創(chuàng)建了一個(gè)文件.但這不是事情應(yīng)該如何運(yùn)作的方式.

I manually copied the FolderId through my browser after the app created it and then pasted to my android code and the app created a file successfully. But this is not how things should work.

我想等待同步完成嗎?如果是,如何?

Am I suppose to wait for the sync to complete and if so, how?

提前謝謝你!

推薦答案

你的問(wèn)題大概可以找到答案 這里.你得到的 DriveId 沒(méi)問(wèn)題,但你不應(yīng)該直接處理它.它是一個(gè)'初步' DriveId,在提交對(duì)象后會(huì)發(fā)生變化(再次,請(qǐng)參閱 SO 22874657).您可以比較您獲得的 DriveId 與您將在onCompletion(CompletionEvent 事件)"中獲得的 DriveId 來(lái)測(cè)試它.

The answer to your problem can probably be found here. The DriveId you're getting is OK, but you should not handle it directly. It is a 'preliminary' DriveId that changes after the object has been committed (again, see SO 22874657). You can test it comparing DriveId you're getting vs. DriveId you'll get in 'onCompletion(CompletionEvent event)'.

這只是 GDAA 邏輯的副作用之一,可以保護(hù)您免受在線/離線網(wǎng)絡(luò)狀態(tài)的影響,從而導(dǎo)致無(wú)法預(yù)測(cè)的延遲.你只需要依賴回調(diào).

This is just one of the side effects of GDAA's logic, shielding you from on-line / off-line network state resulting in unpredictable delays. You just have to rely on callbacks.

但令我驚訝的是,您不能立即將此初步"DriveId(如果是文件夾)用作另一個(gè)對(duì)象(文件夾/文件)的父級(jí).我從未經(jīng)歷過(guò),立即將初步"DriveId 傳遞給另一個(gè) GDAA 方法.
在 ResourceId 的情況下是不同的.那個(gè)在 GDAA 中是次要的,僅在您離開(kāi)設(shè)備時(shí)使用.在提交(上傳)對(duì)象之前,GDAA 并不知道.

But I am surprised that you can't use this 'preliminary' DriveId (in case of a folder) immediately as a parent of another object (folder/file). I have never experienced it, passing the 'preliminary' DriveId immediately to another GDAA method.
It is different in case of the ResourceId. That one is secondary in the GDAA and is used only if you go outside of the device. It is not known to the GDAA until the object is committed (uploaded).

我在這個(gè) demo 中使用了類似的邏輯(創(chuàng)建文件夾/文件樹)(參見(jiàn) MainActivity.createTree() 方法).歡迎您挖掘它.

I used similar logic (creating folder / file tree) in this demo (see MainActivity.createTree() method). You're welcome to dig in it.

中討論了一個(gè)相關(guān)問(wèn)題SO 34318220.

祝你好運(yùn)

這篇關(guān)于Google Drive Android API - 無(wú)效的 DriveId 和 Null ResourceId的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽(tīng)器未觸發(fā)(Google 驅(qū)動(dòng)器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google drive api services account view uploaded files to google drive using java(谷歌驅(qū)動(dòng)api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動(dòng)使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號(hào)返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
Check progress for Upload amp; Download (Google Drive API for Android or Java)(檢查上傳和進(jìn)度下載(適用于 Android 或 Java 的 Google Drive API))
主站蜘蛛池模板: 91热在线 | 亚洲综合资源 | 亚洲日本激情 | 久久久久久网站 | 99久久精品国产毛片 | 欧美一a | 99热精品久久 | 国产精品1区2区3区 欧美 中文字幕 | 日本特黄特色aaa大片免费 | 成人久久久| 欧美不卡一区二区三区 | 91精品国产一区二区三区蜜臀 | 美女天天干天天操 | 精品九九 | 一区二区三区高清不卡 | 国产一卡二卡三卡 | 久国产视频 | 色呦呦网站 | 国产精品久久久久久久久久 | 日韩欧美国产精品综合嫩v 一区中文字幕 | 免费久草| 亚洲国产欧美在线 | 亚洲一区二区免费看 | 国产精品色哟哟网站 | 色婷婷综合成人av | 国产亚洲成av人片在线观看桃 | 日本高清精品 | 免费观看一级视频 | 日韩在线视频观看 | 伊人色综合久久久天天蜜桃 | 日本午夜一区 | 狠狠久久 | 中文字幕高清av | 五月天婷婷久久 | 成人精品网| 久久久综合 | 久久99精品国产 | 超碰97在线免费 | 中文字幕高清 | 欧美 日韩 在线播放 | 最近免费日本视频在线 |