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

Google Drive Android API - 無效的 DriveId 和 Null Resourc

Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
本文介紹了Google Drive Android API - 無效的 DriveId 和 Null ResourceId的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我整天都在與這段代碼作斗爭,但沒有運氣.我從以下代碼開始 示例來自 Google.

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

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

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());
    }
  };
}

每當我運行此代碼時,我都會得到以下看起來不完整的 id:

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

CAESABi2VyCCzdWOuVMoAQ==

我不知道這里發生了什么!

I don't know what is happening here!

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

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

我在 SO 上看到了幾乎類似的問題,但沒有一個對我有用.

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

我在應用創建后通過瀏覽器手動復制了 FolderId,然后粘貼到我的 android 代碼中,應用成功創建了一個文件.但這不是事情應該如何運作的方式.

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?

提前謝謝你!

推薦答案

你的問題大概可以找到答案 這里.你得到的 DriveId 沒問題,但你不應該直接處理它.它是一個'初步' DriveId,在提交對象后會發生變化(再次,請參閱 SO 22874657).您可以比較您獲得的 DriveId 與您將在onCompletion(CompletionEvent 事件)"中獲得的 DriveId 來測試它.

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 邏輯的副作用之一,可以保護您免受在線/離線網絡狀態的影響,從而導致無法預測的延遲.你只需要依賴回調.

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(如果是文件夾)用作另一個對象(文件夾/文件)的父級.我從未經歷過,立即將初步"DriveId 傳遞給另一個 GDAA 方法.
在 ResourceId 的情況下是不同的.那個在 GDAA 中是次要的,僅在您離開設備時使用.在提交(上傳)對象之前,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).

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

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

中討論了一個相關問題SO 34318220.

祝你好運

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

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

相關文檔推薦

Upload progress listener not fired (Google drive API)(上傳進度偵聽器未觸發(Google 驅動器 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(谷歌驅動api服務賬戶查看上傳文件到谷歌驅動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務帳號返回 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)(檢查上傳和進度下載(適用于 Android 或 Java 的 Google Drive API))
主站蜘蛛池模板: 国产又色又爽又黄又免费 | 天天射影院 | 欧美国产激情 | 亚洲精品在线免费 | 91久久精品日日躁夜夜躁欧美 | 秋霞午夜鲁丝一区二区老狼 | 久久久久国产一区二区三区 | 91精品又粗又猛又爽 | 在线国产91 | 国产成人精品网站 | 欧美成人精品 | 麻豆亚洲一区 | 解开岳的丰满奶罩bd | 久草超碰| 亚洲精品在线免费 | 911亚洲精品 | 一区二区三区网站 | 国产精品911 | 精品一区二区三区免费看 | 97国产视频 | 成人理论影院 | 亚洲精品久久久久avwww潮水 | 在线看91| a级片免费观看 | 在线免费看a| 男女视频网站 | 亚洲一区视频 | 黄色一区二区三区 | 九色网址 | 草草福利影院 | 午夜精品在线 | 日韩在线视频一区二区三区 | 黑人精品xxx一区一二区 | 第一福利视频 | 国产激情久久 | 深夜福利视频在线观看 | 久久激情综合 | 激情久久久 | 国产午夜一区二区 | 黄色小视频免费看 | 亚洲精品在 |