public final class

GooglePlayServicesUtil

extends Object
java.lang.Object
   ↳ com.google.android.gms.common.GooglePlayServicesUtil

Class Overview

Utility class for verifying that the Google Play services APK is available and up-to-date on this device. The same checks are performed if one uses PlusClient or GoogleAuthUtil connect to the service.

Summary

Constants
String GOOGLE_PLAY_SERVICES_PACKAGE Package name for Google Play services.
int GOOGLE_PLAY_SERVICES_VERSION_CODE Minimum Google Play services package version (declared in AndroidManifest.xml android:versionCode) in order to be compatible with this client version.
String GOOGLE_PLAY_STORE_PACKAGE Package name for Google Play services.
Public Methods
static Dialog getErrorDialog(int errorCode, Activity activity, int requestCode, DialogInterface.OnCancelListener cancelListener)
Returns a dialog to address the provided errorCode.
static Dialog getErrorDialog(int errorCode, Activity activity, int requestCode)
Returns a dialog to address the provided errorCode.
static PendingIntent getErrorPendingIntent(int errorCode, Context context, int requestCode)
Returns a PendingIntent to address the provided errorCode.
static String getErrorString(int errorCode)
Returns a human-readable string of the error code returned from isGooglePlayServicesAvailable(Context).
static String getOpenSourceSoftwareLicenseInfo(Context context)
Returns the open source software license information for the Google Play services application, or null if Google Play services is not available on this device.
static Context getRemoteContext(Context context)
This gets the Context object of the Buddy APK.
static Resources getRemoteResource(Context context)
This gets the Resources object of the Buddy APK.
static int isGooglePlayServicesAvailable(Context context)
Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.
static boolean isUserRecoverableError(int errorCode)
Determines whether an error is user-recoverable.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String GOOGLE_PLAY_SERVICES_PACKAGE

Package name for Google Play services.

Constant Value: "com.google.android.gms"

public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE

Minimum Google Play services package version (declared in AndroidManifest.xml android:versionCode) in order to be compatible with this client version.

Constant Value: 4030000 (0x003d7e30)

public static final String GOOGLE_PLAY_STORE_PACKAGE

Package name for Google Play services.

Constant Value: "com.android.vending"

Public Methods

public static Dialog getErrorDialog (int errorCode, Activity activity, int requestCode, DialogInterface.OnCancelListener cancelListener)

Returns a dialog to address the provided errorCode. The returned dialog displays a localized message about the error and upon user confirmation (by tapping on dialog) will direct them to the Play Store if Google Play services is out of date or missing, or to system settings if Google Play services is disabled on the device.

Parameters
errorCode error code returned by isGooglePlayServicesAvailable(Context) call. If errorCode is SUCCESS then null is returned.
activity parent activity for creating the dialog, also used for identifying language to display dialog in.
requestCode The requestCode given when calling startActivityForResult.
cancelListener The DialogInterface.OnCancelListener to invoke if the dialog is canceled.

public static Dialog getErrorDialog (int errorCode, Activity activity, int requestCode)

Returns a dialog to address the provided errorCode. The returned dialog displays a localized message about the error and upon user confirmation (by tapping on dialog) will direct them to the Play Store if Google Play services is out of date or missing, or to system settings if Google Play services is disabled on the device.

Parameters
errorCode error code returned by isGooglePlayServicesAvailable(Context) call. If errorCode is SUCCESS then null is returned.
activity parent activity for creating the dialog, also used for identifying language to display dialog in.
requestCode The requestCode given when calling startActivityForResult.

public static PendingIntent getErrorPendingIntent (int errorCode, Context context, int requestCode)

Returns a PendingIntent to address the provided errorCode. It will direct them to one of the following places to either the Play Store if Google Play services is out of date or missing, or system settings if Google Play services is disabled on the device.

Parameters
errorCode error code returned by isGooglePlayServicesAvailable(Context) call. If errorCode is SUCCESS then null is returned.
context parent context for creating the PendingIntent.
requestCode The requestCode given when calling startActivityForResult.

public static String getErrorString (int errorCode)

Returns a human-readable string of the error code returned from isGooglePlayServicesAvailable(Context).

public static String getOpenSourceSoftwareLicenseInfo (Context context)

Returns the open source software license information for the Google Play services application, or null if Google Play services is not available on this device.

public static Context getRemoteContext (Context context)

This gets the Context object of the Buddy APK. This loads the Buddy APK code from the Buddy APK into memory. This returned context can be used to create classes and obtain resources defined in the Buddy APK.

Returns
  • The Context object of the Buddy APK or null if the Buddy APK is not installed on the device.

public static Resources getRemoteResource (Context context)

This gets the Resources object of the Buddy APK.

Returns
  • The Resources object of the Buddy APK or null if the Buddy APK is not installed on the device.

public static int isGooglePlayServicesAvailable (Context context)

Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.

Returns
  • status code indicating whether there was an error. Can be one of following in ConnectionResult: SUCCESS, SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID, DATE_INVALID.

public static boolean isUserRecoverableError (int errorCode)

Determines whether an error is user-recoverable. If true, proceed by calling getErrorDialog(int, Activity, int) and showing the dialog.

Parameters
errorCode error code returned by isGooglePlayServicesAvailable(Context), or returned to your application via onConnectionFailed(ConnectionResult)
Returns