3

Having Google Drive account with folders and files. I want to make android application for adding and geting files to there. Class QUERY is useful, but it can work with data making by application only

The Android Drive API only works with the https://www.googleapis.com/auth/drive.file scope. This means that only files which a user has opened or created with your application can be matched by a query.

Help, please, how can I add files to any folder, that was created via webinterface early?

4

2 に答える 2

1

最新の Google API は使用しないでください。数週間前にリリースされたばかりです。現在のところ、drive.file スコープでのみ動作し、多くの機能 (複数の親の設定など) はまだ実装されておらず、私の経験では、修正が必要なバグもいくつか含まれています。

com.google.android.gms.common.api.GoogleApiClient

代わりに次の API を使用してください。

com.google.api.services.drive.Drive

    try {


        List<String> scopes = new ArrayList<String>();
        scopes.add("https://www.googleapis.com/auth/drive.appdata");
        scopes.add(DriveScopes.DRIVE);

        GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(m_context, scopes);
        credential.setSelectedAccountName(m_account.name);          


        //Get token cannot be run from the main thread;
        //Trying to get a token right away to see if we are authorized

        token = credential.getToken();

        if(token == null){
            Log.e(TAG, "token is null");
        }else{
            Log.i(TAG, "GDrive token: " + token);
            g_drive = new Drive.Builder(
                          AndroidHttp.newCompatibleTransport(),
                          new GsonFactory(), credential).build();

     } catch ( UserRecoverableAuthException e) {
       ....
     }
于 2014-03-06T13:26:28.257 に答える