diff options
| author | 2014-11-07 17:49:58 +0000 | |
|---|---|---|
| committer | 2014-11-07 17:49:58 +0000 | |
| commit | c9ad13a5e18a6eea512547cba6530cb1eb6a9da8 (patch) | |
| tree | 72eebc4396082025164d811240e6c9deaf82a162 | |
| parent | 739117f1a1f70168461a61219b02a90118641e05 (diff) | |
| parent | 58dc8c42f2880b4264bfad46b9ab443576d4b4f2 (diff) | |
am e7cd5f2e: Merge "docs: Add API_UNAVAILABLE case for Wear. Bug: 17753200" into klp-modular-docs
automerge: 58dc8c4
* commit '58dc8c42f2880b4264bfad46b9ab443576d4b4f2':
docs: Add API_UNAVAILABLE case for Wear. Bug: 17753200
| -rw-r--r-- | docs/html/google/auth/api-client.jd | 52 | ||||
| -rw-r--r-- | docs/html/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 <ol> <li><a href="#HandlingFailures">Handle connection failures</a></li> <li><a href="#MaintainingState">Maintain state while resolving an error</a></li> + <li><a href="#WearableApi">Access the Wearable API</a></li> </ol> </li> <li><a href="#Communicating">Communicate with Google Services</a> @@ -104,7 +105,17 @@ additional calls to <a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.Builder.html#addScope(com.google.android.gms.common.api.Scope)" >{@code addScope()}</a>.</p> -<p>However, before you can begin a connection by calling <a +<p class="caution"> +<strong>Important:</strong> To avoid client connection errors on devices that do not have the +<a href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android +Wear app</a> installed, use a separate <a +href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code +GoogleApiClient}</a> instance to access only the <a +href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code +Wearable}</a> API. For more information, see <a href="#WearableApi">Access the Wearable +API</a>.</p> + +<p>Before you can begin a connection by calling <a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html#connect()" >{@code connect()}</a> on the <a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code @@ -408,6 +419,45 @@ consult the corresponding documentation, such as for </p> +<h3 id="WearableApi">Access the Wearable API</h3> + +<p>On devices that do not have the <a +href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android +Wear app</a> installed, connection requests that include the <a +href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code +Wearable}</a> API fail with the <a +href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#API_UNAVAILABLE"> +<code>API_UNAVAILABLE</code></a> error code. If your app uses the <a +href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code +Wearable}</a> API in addition to other Google APIs, use a separate <a +href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code +GoogleApiClient}</a> instance to access the <a +href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code +Wearable}</a> API. This approach enables you to access other Google APIs on devices that are not +paired with a wearable device.</p> + +<p>When you use a separate <a +href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code +GoogleApiClient}</a> instance to access only the Wearable API, you can determine +whether the <a +href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android +Wear app</a> is installed on the device:</p> + +<pre> +// 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 + } + ... +} +</pre> + + + + <h2 id="Communicating">Communicate with Google Services</h2> 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(); </pre> +<p class="caution"> +<strong>Important:</strong> To avoid client connection errors on devices that do not have the +<a href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android +Wear app</a> installed, use a separate <a +href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code +GoogleApiClient}</a> instance to access only the <a +href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code +Wearable}</a> API. For more information, see <a +href="{@docRoot}google/auth/api-client.html#WearableApi">Access the Wearable API</a>.</p> + <p>Before you use the data layer API, start a connection on your client by calling the <a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html#connect()">connect()</a> method, as described in <a href="{@docRoot}google/auth/api-client.html#Starting">Accessing Google Play services APIs</a>. When the system invokes the <code>onConnected()</code> callback for your client, you're ready -to use the data layer API.</p>
\ No newline at end of file +to use the data layer API.</p> |