2017-09-23 1 views
1

ich diesen Code bin mit:Abfrage schlägt fehl Google Drive Android

GoogleApiClient client = new GoogleApiClient.Builder(this).addApi(Drive.API) 
       .addScope(Drive.SCOPE_FILE) 
       .addScope(Drive.SCOPE_APPFOLDER) 
       .build(); 
Query query = new Query.Builder().addFilter(Filters.and(Filters.and(Filters.and(Filters.eq 
        (SearchableField.TITLE, getString(R.string.app_name)), Filters 
        .eq(SearchableField.TRASHED, false)), Filters.eq(SearchableField.PARENTS, Collections 
        .singletonList(Drive.DriveApi 
        .getRootFolder(client) 
        .getDriveId()))), Filters.eq(SearchableField.MIME_TYPE, GoogleDriveClient.FOLDER_MIME))).build(); 
      DriveApi.MetadataBufferResult result = Drive.DriveApi.query(client, query).await(TIMEOUT, TimeUnit.SECONDS); 
      if (!result.getStatus().isSuccess()) { 
       client.disconnect(); 
       return; 
      } 

Es gibt immer einen Fehler: Status{statusCode=INTERNAL_ERROR, resolution=null}

ich das Laufwerk Api in Google-Konsole aktiviert, überprüfte ich wieder meine SHA1-Fingerabdruck und andere Operationen funktionieren. Darf eine Abfrage durchgeführt werden? Hier

Antwort

1

ist eine Dokumentation für Querying for Files

You can use the com.google.android.gms.drive.query package to search a user's Drive account for files whose metadata match your search criteria. You can issue a query for a specific folder or on the entire filesystem.

Note: 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.

Hier ist ein Beispiel Abfragen zu erstellen ist.

A query is created by building an instance of the Query class and specifying the search criteria with Filters . The following example finds all files with the title "HelloWorld.java".

Query query = new Query.Builder() 
     .addFilter(Filters.eq(SearchableField.TITLE, "HelloWorld.java")) 
     .build(); 

You can use the Filters class to build expressions. Multiple filters can be joined together using the and and or methods.

Once a Query object has been constructed it can be executed on the entire file system using Drive.DriveApi as follows:

Drive.DriveApi.query(googleApiClient, query); 

This query starts in the My Drive (the root) folder and recursively traverse the entire filesystem, returning all entries matching the Filters expression tree.

A query can alternatively be executed only in a specific folder using an instance of the DriveFolder class, as shown by:

DriveFolder folder= ...; 
folder.query(query); 

This call does not scan recursively; only direct entries in this folder matching filter conditions are returned.

Verwandte Themen