diff options
Diffstat (limited to 'docs/html/google/play-services/setup.jd')
-rw-r--r-- | docs/html/google/play-services/setup.jd | 134 |
1 files changed, 78 insertions, 56 deletions
diff --git a/docs/html/google/play-services/setup.jd b/docs/html/google/play-services/setup.jd index ad19cb3..70e7107 100644 --- a/docs/html/google/play-services/setup.jd +++ b/docs/html/google/play-services/setup.jd @@ -67,7 +67,7 @@ apply plugin: 'com.android.application' dependencies { compile 'com.android.support:appcompat-v7:21.0.3' - <strong>compile 'com.google.android.gms:play-services:6.5.87'</strong> + <strong>compile 'com.google.android.gms:play-services:7.0.0'</strong> } </pre> <p>Be sure you update this version number each time Google Play services is updated.</p> @@ -82,14 +82,6 @@ see <a href="#split">Selectively compiling APIs into your executable</a>. <img src="{@docRoot}images/tools/sync-project.png" style="vertical-align:bottom;margin:0;height:19px" /> in the toolbar. </li> - <li>Open your app's manifest file and add the following tag as a child of the <a -href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application>}</a> -element: -<pre> -<meta-data android:name="com.google.android.gms.version" - android:value="@integer/google_play_services_version" /> -</pre> - </li> </ol> <p>You can now begin developing features with the @@ -106,14 +98,14 @@ example, to include only the Google Fit and Android Wear APIs, replace the follo <code>build.gradle</code> file:</p> <pre class="no-pretty-print"> -compile 'com.google.android.gms:play-services:6.5.87' +compile 'com.google.android.gms:play-services:7.0.0' </pre> <p>with these lines:</p> <pre class="no-pretty-print"> -compile 'com.google.android.gms:play-services-fitness:6.5.87' -compile 'com.google.android.gms:play-services-wearable:6.5.87' +compile 'com.google.android.gms:play-services-fitness:7.0.0' +compile 'com.google.android.gms:play-services-wearable:7.0.0' </pre> <p>Table 1 shows a list of the separate APIs that you can include when compiling your app, and @@ -129,67 +121,78 @@ you include an API that does have a separate library.)</p> <th scope="col">Google Play services API</th> <th scope="col">Description in <code>build.gradle</code></th> </tr> - <tr> + <tr> <td>Google+</td> - <td>com.google.android.gms:play-services-plus:6.5.87</td> + <td>com.google.android.gms:play-services-plus:7.0.0</td> </tr> <tr> <td>Google Account Login</td> - <td>com.google.android.gms:play-services-identity:6.5.87</td> + <td>com.google.android.gms:play-services-identity:7.0.0</td> </tr> <tr> - <td>Google Activity Recognition</td> - <td>com.google.android.gms:play-services-location:6.5.87</td> + <td>Google Actions, Base Client Library</td> + <td>com.google.android.gms:play-services-base:7.0.0</td> </tr> <tr> <td>Google App Indexing</td> - <td>com.google.android.gms:play-services-appindexing:6.5.87</td> + <td>com.google.android.gms:play-services-appindexing:7.0.0</td> + </tr> + <tr> + <td>Google Analytics</td> + <td>com.google.android.gms:play-services-analytics:7.0.0</td> </tr> <tr> <td>Google Cast</td> - <td>com.google.android.gms:play-services-cast:6.5.87</td> + <td>com.google.android.gms:play-services-cast:7.0.0</td> + </tr> + <tr> + <td>Google Cloud Messaging</td> + <td>com.google.android.gms:play-services-gcm:7.0.0</td> </tr> <tr> <td>Google Drive</td> - <td>com.google.android.gms:play-services-drive:6.5.87</td> + <td>com.google.android.gms:play-services-drive:7.0.0</td> </tr> <tr> <td>Google Fit</td> - <td>com.google.android.gms:play-services-fitness:6.5.87</td> + <td>com.google.android.gms:play-services-fitness:7.0.0</td> + </tr> + <tr> + <td>Google Location, Activity Recognition, and Places</td> + <td>com.google.android.gms:play-services-location:7.0.0</td> </tr> <tr> <td>Google Maps</td> - <td>com.google.android.gms:play-services-maps:6.5.87</td> + <td>com.google.android.gms:play-services-maps:7.0.0</td> </tr> <tr> <td>Google Mobile Ads</td> - <td>com.google.android.gms:play-services-ads:6.5.87</td> + <td>com.google.android.gms:play-services-ads:7.0.0</td> + </tr> + <tr> + <td>Google Nearby</td> + <td>com.google.android.gms:play-services-nearby:7.0.0</td> </tr> <tr> <td>Google Panorama Viewer</td> - <td>com.google.android.gms:play-services-panorama:6.5.87</td> + <td>com.google.android.gms:play-services-panorama:7.0.0</td> </tr> <tr> <td>Google Play Game services</td> - <td>com.google.android.gms:play-services-games:6.5.87</td> + <td>com.google.android.gms:play-services-games:7.0.0</td> + </tr> + <tr> + <td>SafetyNet</td> + <td>com.google.android.gms:play-services-safetynet:7.0.0</td> </tr> <tr> <td>Google Wallet</td> - <td>com.google.android.gms:play-services-wallet:6.5.87</td> + <td>com.google.android.gms:play-services-wallet:7.0.0</td> </tr> <tr> <td>Android Wear</td> - <td>com.google.android.gms:play-services-wearable:6.5.87</td> - </tr> - <tr> - <td> - Google Actions<br> - Google Analytics<br> - Google Cloud Messaging<br> - </td> - <td>com.google.android.gms:play-services-base:6.5.87</td> + <td>com.google.android.gms:play-services-wearable:7.0.0</td> </tr> - </table> <p class="note"><strong>Note:</strong> ProGuard directives are included in the Play services @@ -210,13 +213,14 @@ To use ProGuard with Android Studio, you must enable the ProGuard setting in you <p>To make the Google Play services APIs available to your app:</p> <ol> <li>Copy the library project at - <code><android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/</code> +{@code <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/} to the location where you maintain your Android app projects.</li> <li>Import the library project into your Eclipse workspace. Click <b>File > Import</b>, select <b>Android > Existing Android Code into Workspace</b>, and browse to the copy of the library project to import it.</li> <li>In your app project, reference Google Play services library project. See - <a href="{@docRoot}tools/projects/projects-eclipse.html#ReferencingLibraryProject">Referencing a Library Project for Eclipse</a> for more information on how to + <a href="{@docRoot}tools/projects/projects-eclipse.html#ReferencingLibraryProject"> + Referencing a Library Project for Eclipse</a> for more information on how to do this. <p class="note"><strong>Note:</strong> You should be referencing a copy of the library that you copied to your development workspace—you should not @@ -270,7 +274,9 @@ required classes, add the following lines in the <p>To make the Google Play services APIs available to your app:</p> <ol> - <li>Copy the library project at <code><android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/</code> to the location where you maintain your Android app projects.</li> + <li>Copy the library project at +{@code <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/} +to the location where you maintain your Android app projects.</li> <li>In your app project, reference the Google Play services library project. See <a href="{@docRoot}tools/projects/projects-cmdline.html#ReferencingLibraryProject">Referencing @@ -282,7 +288,8 @@ workspace—you should not reference the library directly from the Android S <li>After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the - <a href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application>}</a> element: + <a href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application>}</a> + element: <pre> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> @@ -336,23 +343,39 @@ perform API transactions.</p> <strong>Important:</strong> Because it is hard to anticipate the state of each device, you must <em>always</em> check for a compatible Google Play services APK before you access Google Play services - features. For many apps, the best time to check is during the - {@link android.app.Activity#onResume onResume()} method of the main activity. + features. </p> -<p>The Google Play services library includes utility methods that help you determine whether or not -the Google Play services version on the device supports the version of the client library you are -using. If the version on the device is too old, the system will take the user to Google Play Store -in order to install the recent version of the Google Play services.</p> - <p>Because each app uses Google Play services differently, it's up to you decide the appropriate -place in your app to check verify the Google Play services version. For example, if Google Play +place in your app to verify the Google Play services version. For example, if Google Play services is required for your app at all times, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can check the version only once the user navigates to that portion of your app.</p> -<p>To verify the Google Play services version, call <a href="{@docRoot}reference/com/google/android/gms/common/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable(android.content.Context)" ->{@code isGooglePlayServicesAvailable()}</a>. If the result code is +<p>You are strongly encouraged to use the +<a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html"> +{@code GoogleApiClient}</a> class to access Google Play services features. This approach allows +you to attach an +<a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.OnConnectionFailedListener.html"> +{@code OnConnectionFailedListener}</a> object to your client. +To detect if the device has the appropriate version of the Google Play services APK, implement the +<a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.OnConnectionFailedListener.html#onConnectionFailed(com.google.android.gms.common.ConnectionResult)"> +{@code onConnectionFailed()}</a> +callback method. If the connection fails due to a missing or out-of-date version of +the Google Play APK, the callback receives an error code such as +<a href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_MISSING"> +{@code SERVICE_MISSING}</a>, +<a href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_VERSION_UPDATE_REQUIRED"> +{@code SERVICE_VERSION_UPDATE_REQUIRED}</a>, or +<a href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_DISABLED"> +{@code SERVICE_DISABLED}</a>. To learn more about how to build your client and handle such +connection errors, see <a href="{@docRoot}google/auth/api-client.html">Accessing Google APIs</a>. +</p> + +<p>Another approach is to use the +<a href="{@docRoot}reference/com/google/android/gms/common/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable(android.content.Context)" +>{@code isGooglePlayServicesAvailable()}</a> method. You might call this method in the +{@link android.app.Activity#onResume onResume()} method of the main activity. If the result code is <a href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#SUCCESS" >{@code SUCCESS}</a>, then the Google Play services APK is up-to-date and you can continue to make a connection. @@ -363,12 +386,11 @@ If, however, the result code is >{@code SERVICE_VERSION_UPDATE_REQUIRED}</a>, or <a href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_DISABLED" ->{@code SERVICE_DISABLED}</a>, then the user needs to install an update. So, - call <a href="{@docRoot}reference/com/google/android/gms/common/GooglePlayServicesUtil.html#getErrorDialog(int, android.app.Activity, int)" - >{@code GooglePlayServicesUtil.getErrorDialog()}</a> and pass it the result error code. -This returns a {@link android.app.Dialog} you should show, which provides an appropriate message -about the error and provides an action -that takes the user to Google Play Store to install the update.</p> +>{@code SERVICE_DISABLED}</a>, then the user needs to install an update. In this case, call the +<a href="{@docRoot}reference/com/google/android/gms/common/GooglePlayServicesUtil.html#getErrorDialog(int, android.app.Activity, int)"> +{@code getErrorDialog()}</a> method and pass it the result error code. The method returns a +{@link android.app.Dialog} you should show, which provides an appropriate message about the error +and provides an action that takes the user to Google Play Store to install the update.</p> <p>To then begin a connection to Google Play services (required by most Google APIs such |