From 2871e05b48f0b932885986322ce01212717a6399 Mon Sep 17 00:00:00 2001 From: Ricardo Cervera Date: Fri, 10 Oct 2014 16:04:11 -0700 Subject: docs: Add API_UNAVAILABLE case for Wear. Bug: 17753200 Change-Id: I4fed30061daabfb05b24e84bb36cd21d38ad0fea --- docs/html/google/auth/api-client.jd | 52 +++++++++++++++++++++- .../training/wearables/data-layer/accessing.jd | 13 +++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/docs/html/google/auth/api-client.jd b/docs/html/google/auth/api-client.jd index 5331d1ed9ab0..a0836d1dbd75 100644 --- a/docs/html/google/auth/api-client.jd +++ b/docs/html/google/auth/api-client.jd @@ -15,6 +15,7 @@ startpage=true
  1. Handle connection failures
  2. Maintain state while resolving an error
  3. +
  4. Access the Wearable API
  • Communicate with Google Services @@ -104,7 +105,17 @@ additional calls to {@code addScope()}.

    -

    However, before you can begin a connection by calling +Important: To avoid client connection errors on devices that do not have the +Android +Wear app installed, use a separate {@code +GoogleApiClient} instance to access only the {@code +Wearable} API. For more information, see Access the Wearable +API.

    + +

    Before you can begin a connection by calling {@code connect()} on the {@code @@ -408,6 +419,45 @@ consult the corresponding documentation, such as for

    +

    Access the Wearable API

    + +

    On devices that do not have the Android +Wear app installed, connection requests that include the {@code +Wearable} API fail with the +API_UNAVAILABLE error code. If your app uses the {@code +Wearable} API in addition to other Google APIs, use a separate {@code +GoogleApiClient} instance to access the {@code +Wearable} API. This approach enables you to access other Google APIs on devices that are not +paired with a wearable device.

    + +

    When you use a separate {@code +GoogleApiClient} instance to access only the Wearable API, you can determine +whether the Android +Wear app is installed on the device:

    + +
    +// Connection failed listener method for a client that only
    +// requests access to the Wearable API
    +@Override
    +public void onConnectionFailed(ConnectionResult result) {
    +    if (result.getErrorCode() == ConnectionResult.API_UNAVAILABLE) {
    +        // The Android Wear app is not installed
    +    }
    +    ...
    +}
    +
    + + + +

    Communicate with Google Services

    diff --git a/docs/html/training/wearables/data-layer/accessing.jd b/docs/html/training/wearables/data-layer/accessing.jd index 896a6984b6ad..5183403897ab 100644 --- a/docs/html/training/wearables/data-layer/accessing.jd +++ b/docs/html/training/wearables/data-layer/accessing.jd @@ -55,13 +55,24 @@ GoogleApiClient mGoogleAppiClient = new GoogleApiClient.Builder(this) Log.d(TAG, "onConnectionFailed: " + result); } }) + // Request access only to the Wearable API .addApi(Wearable.API) .build(); +

    +Important: To avoid client connection errors on devices that do not have the +Android +Wear app installed, use a separate {@code +GoogleApiClient} instance to access only the {@code +Wearable} API. For more information, see Access the Wearable API.

    +

    Before you use the data layer API, start a connection on your client by calling the connect() method, as described in Accessing Google Play services APIs. When the system invokes the onConnected() callback for your client, you're ready -to use the data layer API.

    \ No newline at end of file +to use the data layer API.

    -- cgit v1.2.3-59-g8ed1b