久久久久久久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.

問題是該文件夾已成功創(chuàng)建,但在 onResult() 內,我總是得到一個無效或不完整的 DriveId 或 resourceId.這意味著我無法在我創(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());
    }
  };
}

每當我運行此代碼時,我都會得到以下看起來不完整的 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 上搜索并閱讀了添加偵聽器以偵聽完成事件,但它們似乎都不起作用.

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.

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

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,在提交對象后會發(fā)生變化(再次,請參閱 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 邏輯的副作用之一,可以保護您免受在線/離線網(wǎng)絡狀態(tài)的影響,從而導致無法預測的延遲.你只需要依賴回調.

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(如果是文件夾)用作另一個對象(文件夾/文件)的父級.我從未經(jīng)歷過,立即將初步"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 中使用了類似的邏輯(創(chuàng)建文件夾/文件樹)(參見 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模板網(wǎng)!

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

相關文檔推薦

Upload progress listener not fired (Google drive API)(上傳進度偵聽器未觸發(fā)(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))
主站蜘蛛池模板: 日韩午夜场| 日韩中文字幕在线观看 | 男女网站在线观看 | 亚洲vs天堂 | 操操操操操 | 日本一区二区影视 | 欧美综合一区 | 亚洲va欧美va天堂v国产综合 | 国产精品国产 | 亚洲精品乱码久久久久久蜜桃 | 在线观看h视频 | 最新免费视频 | 亚洲性人人天天夜夜摸 | 日韩成人免费av | 国产九九九九 | 精品欧美一区二区精品久久 | 国产精品久久精品 | 性一交一乱一透一a级 | 香蕉久久久久久 | 亚洲一区二区三区免费 | www国产亚洲精品久久网站 | www.成人在线视频 | 国产农村一级片 | 毛片免费视频 | 日日天天 | 亚洲精品视频导航 | 欧美激情 一区 | 91视频国产区 | 蜜桃视频在线观看免费视频网站www | 久久黄网 | 欧美多人在线 | 自拍偷拍在线视频 | 久久成人国产精品 | 久久999 | 国产精品视频久久久久 | 日日骚网| 日韩在线视频观看 | 在线免费国产 | 久久久久亚洲精品中文字幕 | 丝袜久久 | 综合久久99|