久久久久久久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的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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

問題是該文件夾已成功創(chuàng)建,但在 onResult() 內(nèi),我總是得到一個(gè)無效或不完整的 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());
    }
  };
}

每當(dāng)我運(yùn)行此代碼時(shí),我都會(huì)得到以下看起來不完整的 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 上看到了幾乎類似的問題,但沒有一個(gè)對(duì)我有用.

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

我在應(yīng)用創(chuàng)建后通過瀏覽器手動(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?

提前謝謝你!

推薦答案

你的問題大概可以找到答案 這里.你得到的 DriveId 沒問題,但你不應(yīng)該直接處理它.它是一個(gè)'初步' DriveId,在提交對(duì)象后會(huì)發(fā)生變化(再次,請(qǐng)參閱 SO 22874657).您可以比較您獲得的 DriveId 與您將在onCompletion(CompletionEvent 事件)"中獲得的 DriveId 來測(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)致無法預(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)歷過,立即將初步"DriveId 傳遞給另一個(gè) GDAA 方法.
在 ResourceId 的情況下是不同的.那個(gè)在 GDAA 中是次要的,僅在您離開設(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)建文件夾/文件樹)(參見 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)問題SO 34318220.

祝你好運(yùn)

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

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

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽器未觸發(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))
主站蜘蛛池模板: 久久99一区二区 | 国外成人在线视频网站 | 日韩一 | 精品一区二区三区四区 | 久久久精品网站 | 高清一区二区三区 | 黄色成人免费在线观看 | 日韩午夜| www.夜夜骑 | 欧美一级一区 | 99看片网| 国产欧美日韩视频 | 久久精品中文字幕 | 四虎影院久久 | 欧美激情综合 | 欧美a在线看| 欧洲成人 | 国产伦精品一区二区三区四区视频 | 精品国产精品国产偷麻豆 | 亚洲精品一二三 | 日韩欧美在线观看视频 | 亚洲精品久久久久久一区二区 | 久久综合888 | 国产成人免费视频网站视频社区 | 91精品国产一区二区三区动漫 | 日韩欧美亚洲 | 精品乱码一区二区三四区视频 | 一区二区三区中文字幕 | 久久大陆 | 欧美精品久久久久久久久久 | 久久精品欧美一区二区三区不卡 | 国产午夜高清 | 日韩一区二区在线视频 | 成人免费网站在线 | 99热这里都是精品 | 国产精品网址 | 久久久这里只有17精品 | 夜夜精品浪潮av一区二区三区 | 亚洲欧洲精品一区 | 欧美一区二区三区视频在线播放 | 91视频在线观看 |