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

在 Android 上獲取所有文件夾 google drive api

Get all folders google drive api on Android(在 Android 上獲取所有文件夾 google drive api)
本文介紹了在 Android 上獲取所有文件夾 google drive api的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我使用新的 Google drive api,但無法從我的 google drive 中獲取所有文件夾,我只能獲取使用 google drive api 創(chuàng)建的文件夾...有人知道為什么會這樣嗎?

I use the new Google drive api and I can't get All folders from my google drive, I only get the folders that I create with the google drive api... Anybody know why happens this?

這是我的代碼:

@Override
    protected void onResume() {
        super.onResume();
        if (mGoogleApiClient == null) {
            // Create the API client and bind it to an instance variable.
            // We use this instance as the callback for connection and connection
            // failures.
            // Since no account name is passed, the user is prompted to choose.
            mGoogleApiClient = new GoogleApiClient.Builder(this)
                    .addApi(Drive.API)
                    .addScope(Drive.SCOPE_FILE)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .build();
        }
        // Connect the client. Once connected, the camera is launched.
        mGoogleApiClient.connect();
    }


    /**
     * Handles resolution callbacks.
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_RESOLUTION && resultCode == RESULT_OK) {
            mGoogleApiClient.connect();

        }
    }

    /**
     * Called when activity gets invisible. Connection to Drive service needs to
     * be disconnected as soon as an activity is invisible.
     */
    @Override
    protected void onPause() {
        if (mGoogleApiClient != null) {
            mGoogleApiClient.disconnect();
        }
        super.onPause();
    }

    /**
     * Called when {@code mGoogleApiClient} is connected.
     */
    @Override
    public void onConnected(Bundle connectionHint) {
        Log.i(TAG, "GoogleApiClient connected");

        rootFolder = Drive.DriveApi.getRootFolder(mGoogleApiClient);

       rootFolder.listChildren(getGoogleApiClient()).setResultCallback(pruebaChildren);

    }


    ResultCallback<DriveApi.MetadataBufferResult> pruebaChildren = new
            ResultCallback<DriveApi.MetadataBufferResult>() {
                @Override
                public void onResult(DriveApi.MetadataBufferResult metadataBufferResult) {
                    if (!metadataBufferResult.getStatus().isSuccess()) {
                        showMessage("Problem while retrieving files");
                        return;
                    }
                    Log.i(TAG,"got root folder");
                    MetadataBuffer buffer = metadataBufferResult.getMetadataBuffer();
                    Log.i(TAG,"Buffer count  " + buffer.getCount());
                    if(buffer.getCount() == 0){
                        createFolderApp();
                    }
                    else{
                        for(Metadata m : buffer){
                            Log.i(TAG,"Metadata name  " + m.getTitle() + "(" + (m.isFolder() ? "folder" : "file") + ")");
                            if (m.isFolder() && m.getTitle().equals(TAG)){
                                Log.i(TAG,"APP FOLDER FOUND");
                                Drive.DriveApi.getFolder(mGoogleApiClient, m.getDriveId())
                                        .listChildren(mGoogleApiClient)
                                        .setResultCallback(foreachAppAplication);
                            }
                        }
                    }
                    return;
                }
            };

現(xiàn)在我想查看 rootFolder Drive 中的所有文件夾,我嘗試了 requestSync() 但結(jié)果是一樣的......我需要幫助!

And now I want see all folders in rootFolder Drive, I try the requestSync() but the result is same... I need help please!

還有一個問題:如何設(shè)置 AppFolder?我只看到 getAppFolder 但如何設(shè)置??

And another question: How I can set the AppFolder? I only see getAppFolder but How I can set ??

謝謝

推薦答案

根據(jù)設(shè)計,GDAA 僅支持FILE 范圍,即它將僅查找/列出 Android 應(yīng)用創(chuàng)建的文件夾/文件.

By design, GDAA supports only the FILE scope, i.e. it will find / list only folders / files created by the Android app.

有兩種解決方法:

  1. 使用 GDAA 的 intents 之一,基本上讓用戶選擇文件/文件夾.這樣,您的應(yīng)用就可以使用它.
  2. 使用不同的 API,即 REST Api,它支持 DRIVE 范圍,為您的應(yīng)用提供完整的一組文件/文件夾.
  1. Use one of the intents of the GDAA, basically letting the user pick the file / folder. That way it will become available to your app.
  2. Use a different API, the REST Api, which supports the DRIVE scope, giving your app full set of files / folders.

如果您想研究這兩個 API 的行為方式,我在 Github 上放了兩個不同的演示(REST和 GDAA CRUD 演示包裝器).

In case you want to study how the two APIs behave, I've put two different demos on the Github (the REST and the GDAA CRUD demo wrappers).

您問題的第二部分沒有答案.您不設(shè)置應(yīng)用程序文件夾,您只能獲取它的 DriveFolder id.您可以使用它來創(chuàng)建/檢索對象.

The second part of your question does not have answer. You don't set the app folder, you can only get it's DriveFolder id. You use it to create / retrieve objects.

  DriveFolder appFldr = Drive.DriveApi.getAppFolder(mGooleApiClient);
  appFldr.createFile(...);
  appFldr.createFolder(...);
  appFldr.listChildren(...);
  appFldr.queryChildren(...);

...并且不要忘記添加 SCOPE_APPFOLDER 范圍

... and don't forget to add the SCOPE_APPFOLDER scope

祝你好運

這篇關(guān)于在 Android 上獲取所有文件夾 google drive api的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進度偵聽器未觸發(fā)(Google 驅(qū)動器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅(qū)動api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 成人av网站在线观看 | 一级黄色录像片子 | 久久在线免费 | 黄色免费网站在线看 | 亚洲国产高清免费 | 午夜视频一区二区 | 国产视频久 | 国产精品久久久久久影院8一贰佰 | 伊人网91| 亚洲www啪成人一区二区麻豆 | 一区二区av| 99re| 人人干97| 欧美日韩精品亚洲 | 日日摸日日碰夜夜爽2015电影 | 一区二区三区视频在线免费观看 | 国产精品欧美一区二区三区 | 成人在线观看免费视频 | 成人不卡 | 欧美一区免费 | 国产精品久久国产精品久久 | 涩涩视频在线看 | 亚洲精品视频免费 | 伊人久久国产 | 久久一二区 | 国产成人99久久亚洲综合精品 | 中文字幕黄色大片 | 欧美99 | 影音先锋中文字幕在线观看 | 日韩专区中文字幕 | 玖玖视频网 | 怡红院怡春院一级毛片 | 在线免费观看黄色网址 | 亚洲精品一区中文字幕乱码 | 久久久久国产 | 日日干干夜夜 | 欧美一区二区三区在线免费观看 | 国产一区二区三区免费观看视频 | 日韩成人免费av | 欧美不卡在线 | av性色|