@@ -8,7 +8,7 @@ If you are developing for Android and the Google API you want to use is included
88in the [ Google Play Services library] [ play-services ] , use that library for the
99best performance and experience.
1010
11- To access other Google APIs, use the Google Client Library for Java's
11+ To access other Google APIs, use the Google APIs Client Library for Java's
1212Android-specific helper classes, which are well-integrated with
1313[ Android AccountManager] [ account-manager ] .
1414
@@ -51,19 +51,29 @@ fields are returned to you in the HTTP response. This can significantly reduce
5151the size of the response, thereby reducing network usage, parsing response time,
5252and memory usage. It works with both JSON and XML.
5353
54- The following snippet of code drawn from the Google+ Sample demonstrates how to
55- use the partial-response protocol:
56-
54+ The following snippet of code drawn from the [ Google Drive API Quickstart ] [ quickstart ]
55+ demonstrates how to use the partial-response protocol. The ` setFields ` method
56+ identifies the fields you want returned:
5757
5858``` java
59- Plus . Activities . List listActivities = plus. activities(). list(" me" , " public" );
60- listActivities. setMaxResults(5L );
61- // Pro tip: Use partial responses to improve response time considerably
62- listActivities. setFields(" nextPageToken,items(id,URL,object/content)" );
63- ActivityFeed feed = listActivities. execute();
59+ // Print the names and IDs for up to 10 files.
60+ FileList result = service. files(). list()
61+ .setPageSize(10 )
62+ .setFields(" nextPageToken, files(id, name)" )
63+ .execute();
64+ List<File > files = result. getFiles();
65+ if (files == null || files. isEmpty()) {
66+ System . out. println(" No files found." );
67+ } else {
68+ System . out. println(" Files:" );
69+ for (File file : files) {
70+ System . out. printf(" %s (%s)\n " , file. getName(), file. getId());
71+ }
72+ }
6473```
6574
6675[ play-services ] : https://developer.android.com/google/play-services/index.html
6776[ account-manager ] : http://developer.android.com/reference/android/accounts/AccountManager.html
6877[ http-client-android ] : https://github.com/googleapis/google-http-java-client/wiki/Android
6978[ oauth2-android ] : https://github.com/googleapis/google-api-java-client#oauth2-android
79+ [ quickstart ] : https://developers.google.com/drive/api/v3/quickstart/java
0 commit comments