Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions docs/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you are developing for Android and the Google API you want to use is included
in the [Google Play Services library][play-services], use that library for the
best performance and experience.

To access other Google APIs, use the Google Client Library for Java's
To access other Google APIs, use the Google APIs Client Library for Java's
Android-specific helper classes, which are well-integrated with
[Android AccountManager][account-manager].

Expand Down Expand Up @@ -51,19 +51,29 @@ fields are returned to you in the HTTP response. This can significantly reduce
the size of the response, thereby reducing network usage, parsing response time,
and memory usage. It works with both JSON and XML.

The following snippet of code drawn from the Google+ Sample demonstrates how to
use the partial-response protocol:

The following snippet of code drawn from the [Google Drive API Quickstart][quickstart]
demonstrates how to use the partial-response protocol. The `setFields` method
identifies the fields you want returned:

```java
Plus.Activities.List listActivities = plus.activities().list("me", "public");
listActivities.setMaxResults(5L);
// Pro tip: Use partial responses to improve response time considerably
listActivities.setFields("nextPageToken,items(id,URL,object/content)");
ActivityFeed feed = listActivities.execute();
// Print the names and IDs for up to 10 files.
FileList result = service.files().list()
.setPageSize(10)
.setFields("nextPageToken, files(id, name)")
.execute();
List<File> files = result.getFiles();
if (files == null || files.isEmpty()) {
System.out.println("No files found.");
} else {
System.out.println("Files:");
for (File file : files) {
System.out.printf("%s (%s)\n", file.getName(), file.getId());
}
}
```

[play-services]: https://developer.android.com/google/play-services/index.html
[account-manager]: http://developer.android.com/reference/android/accounts/AccountManager.html
[http-client-android]: https://github.com/googleapis/google-http-java-client/wiki/Android
[oauth2-android]: https://github.com/googleapis/google-api-java-client#oauth2-android
[quickstart]: https://developers.google.com/drive/api/v3/quickstart/java
7 changes: 2 additions & 5 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ When an error status code is detected in an HTTP response to a Google API that
uses the JSON format, the generated libraries throw a
[`GoogleJsonResponseException`][google-json-response-exception].

The errors use the format specified in [Error responses][error-responses].

The following example shows one way that you can handle these exceptions:

```java
Plus.Activities.List listActivities = plus.activities().list("me", "public");
Drive.Files.List listFiles = drive.files.list();
try {
ActivityFeed feed = listActivities.execute();
FileList response = listFiles.execute();
...
} catch (GoogleJsonResponseException e) {
System.err.println(e.getDetails());
Expand All @@ -49,4 +47,3 @@ try {

[google-analytics-api]: https://developers.google.com/analytics/
[google-json-response-exception]: https://googleapis.dev/java/google-api-client/latest/com/google/api/client/googleapis/json/GoogleJsonResponseException.html
[error-responses]: https://developers.google.com/url-shortener/v1/getting_started?csw=1#errors