Merge "docs: Add API_UNAVAILABLE case for Wear. Bug: 17753200" into klp-modular-docs
This commit is contained in:
committed by
Android (Google) Code Review
commit
e7cd5f2e9c
@@ -15,6 +15,7 @@ startpage=true
|
|||||||
<ol>
|
<ol>
|
||||||
<li><a href="#HandlingFailures">Handle connection failures</a></li>
|
<li><a href="#HandlingFailures">Handle connection failures</a></li>
|
||||||
<li><a href="#MaintainingState">Maintain state while resolving an error</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>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#Communicating">Communicate with Google Services</a>
|
<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)"
|
<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>
|
>{@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()"
|
href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html#connect()"
|
||||||
>{@code connect()}</a> on the <a
|
>{@code connect()}</a> on the <a
|
||||||
href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
|
href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
|
||||||
@@ -408,6 +419,45 @@ consult the corresponding documentation, such as for
|
|||||||
</p>
|
</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>
|
<h2 id="Communicating">Communicate with Google Services</h2>
|
||||||
|
|||||||
@@ -55,10 +55,21 @@ GoogleApiClient mGoogleAppiClient = new GoogleApiClient.Builder(this)
|
|||||||
Log.d(TAG, "onConnectionFailed: " + result);
|
Log.d(TAG, "onConnectionFailed: " + result);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Request access only to the Wearable API
|
||||||
.addApi(Wearable.API)
|
.addApi(Wearable.API)
|
||||||
.build();
|
.build();
|
||||||
</pre>
|
</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
|
<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>
|
<a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html#connect()">connect()</a>
|
||||||
method, as described in
|
method, as described in
|
||||||
|
|||||||
Reference in New Issue
Block a user