diff options
Diffstat (limited to 'docs/html/google/play-services/setup.jd')
-rw-r--r-- | docs/html/google/play-services/setup.jd | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/docs/html/google/play-services/setup.jd b/docs/html/google/play-services/setup.jd new file mode 100644 index 0000000..eb3618b --- /dev/null +++ b/docs/html/google/play-services/setup.jd @@ -0,0 +1,142 @@ +page.title=Setup +@jd:body + +<div id="qv-wrapper"> + <div id="qv"> + <h2>In this document</h2> + <ol> + <li><a href="#ensure">Ensuring Devices Have the Google Play services APK</a></li> + </ol> + </div> +</div> + + +<p> + The Google Play services SDK is an extension to the Android SDK and is available to you as a + downloadable SDK component. This download includes the client library and code samples. +</p> + +<p> + Before you get started developing, make sure that you have an updated version of the Android SDK + installed on your computer, including the SDK Tools component. If you don't have the SDK, + visit the <a href="{@docRoot}sdk/index.html">SDK Download page</a> + on the Android Developers site. +</p> + +<p> + To set up the Google Play services SDK: +</p> + +<ol> + <li> + Launch Eclipse and select <b>Window > Android SDK Manager</b> or run <code>android</code> + at the command line. + </li> + <li> + Scroll to the bottom of the package list and select <b>Extras > Google Play services</b>. + The Google Play services SDK is downloaded to your computer and installed in your Android SDK environment at + <code><android-sdk-folder>/extras/google/google_play_services/</code>. + </li> + <li>Copy the <code><android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib</code> + library project to a location in your project's source tree.</li> + <li>If you are using Eclipse, import the library project into your 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> + <li>Reference the library project in your Android project. See the + <a href="{@docRoot}tools/projects/projects-eclipse.html#ReferencingLibraryProject">Referencing a Library Project for Eclipse</a> + or <a href="{@docRoot}tools/projects/projects-cmdline.html#ReferencingLibraryProject">Referencing a Library Project on the Command Line</a> + for more information on how to do this. + </li> + <li>If you are using <a href="{@docRoot}tools/help/proguard.html">ProGuard</a>, add the following + lines in the <code><project_directory>/proguard-project.txt</code> file + to prevent ProGuard from stripping away required classes: +<pre> +-keep class * extends java.util.ListResourceBundle { + protected Object[][] getContents(); +} +</pre> +</ol> + +<h2 id="ensure">Ensuring Devices Have the Google Play services APK</h2> +<p> + Google Play delivers updates to the majority of the devices that support Google Play services + (Android 2.2 devices with the Google Play Store app installed). However, updates might not reach + supported devices in a timely manner, which are desribed in the following four scenarios: +<p class="note"> +<strong>Important:</strong> +<span> + Because it is hard to anticipate the state devices are in, you must <em>always</em> check for a + compatible Google Play services APK in your app when you are accessing Google Play services + features. For many apps, this is each time in the + {@link android.app.Activity#onResume onResume()} method of the main activity. +</span> +</p> +<ol> + <li> + A recent version of the Google Play Store app is installed, and the most recent Google Play + services APK has been downloaded. + </li> + <li> + A recent version of the Google Play Store app is installed, but the most recent Google Play + services APK has <em>not</em> been downloaded. + </li> + <li> + An old version of the Google Play Store app, which does not proactively download Google Play + services updates, is present. + </li> + <li> + The Google Play services APK is missing or disabled on the device, which might happen if the + user explicitly uninstalls or disables it. + </li> +</ol> +<p> + Case 1 is the success scenario and is the most common. However, because the other scenarios can + still happen, you must handle them every time your app connects to a Google Play service to + ensure that the Google Play services APK is present, up-to-date, and enabled. +</p> +<p> + To help you, the Google Play services client library has utility methods to assist in + determining whether or not the Google Play services APK is recent enough to support the + version of the client library that you are using. If not, the client library sends users to the + Google Play Store to download a recent version of the Google Play services APK. +</p> + +<p class="note"> +<b>Note:</b> +<span> + The Google Play services APK is not visible by searching the Google Play Store. The client + library provides a deep link into the Google Play Store when it detects that the device has a + missing or incompatible Google Play services APK. +</span> +</p> + +<p> + It is up to you choose the appropriate place in your app to do the following steps to check for + a valid Google Play services APK. For example, if Google Play services is required for your app, + 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 do these checks if the user navigates to that portion + of your app: +</p> + +<ol> + <li> + Query for the status of Google Play services on the device with the +<a href="{@docRoot}google/play-services/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable(android.content.Context)">isGooglePlayServicesAvailable()</a> + method, which returns a result code. + </li> + <li> + If the result code is +<a href="{@docRoot}google/play-services/reference/com/google/android/gms/common/ConnectionResult.html#SUCCESS">SUCCESS</a>, + then the Google Play services APK is up-to-date, and you can proceed as normal. + </li> + <li> + If the result is +<a href="{@docRoot}google/play-services/reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_MISSING">SERVICE_MISSING</a>, +<a href="{@docRoot}google/play-services/reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_VERSION_UPDATE_REQUIRED">SERVICE_VERSION_UPDATE_REQUIRED</a>, + or +<a href="{@docRoot}google/play-services/reference/com/google/android/gms/common/ConnectionResult.html#SERVICE_DISABLED">SERVICE_DISABLED</a>, + call <a href="{@docRoot}google/play-services/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#getErrorDialog(int, android.app.Activity, int)">getErrorDialog()</a> + to display an error message to the user, which will then allow the user to download the APK + from the Google Play Store or enable it in the device's system settings. + </li> +</ol>
\ No newline at end of file |