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 usesAdvertisingIdClient
orGoogleAuthUtil
to connect to the service.
Constant Summary
String | GMS_ERROR_DIALOG | |
String | GOOGLE_PLAY_SERVICES_PACKAGE | This constant is deprecated. Use
GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE instead. |
String | GOOGLE_PLAY_STORE_PACKAGE | Package name for Google Play Store. |
Field Summary
public static final int | GOOGLE_PLAY_SERVICES_VERSION_CODE | This field is deprecated. Use
GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE instead. |
Public Method Summary
staticDialog |
getErrorDialog(int errorCode,Activity
activity, int requestCode)
This method is deprecated. Use
GoogleApiAvailability.getErrorDialog(Activity, int, int)
instead.
|
staticDialog |
getErrorDialog(int errorCode,Activity
activity, int requestCode,
DialogInterface.OnCancelListenercancelListener)
This method is deprecated. Use
GoogleApiAvailability.getErrorDialog(Activity, int, int,
OnCancelListener) instead.
|
staticPendingIntent |
getErrorPendingIntent(int errorCode,Context
context, int requestCode)
This method is deprecated. Use
GoogleApiAvailability.getErrorResolutionPendingIntent(Context,
ConnectionResult) instead.
|
staticString |
getErrorString(int errorCode)
This method is deprecated. Use
GoogleApiAvailability.getErrorString(int) instead.
|
staticString |
getOpenSourceSoftwareLicenseInfo(Context
context)
This method is deprecated. This license information is displayed in
Settings > Google > Open Source on any device running Google Play
services. Applications do not need to display this license text, and this
method will be removed in a future version of Google Play services.
|
staticContext | |
staticResources | |
static int |
isGooglePlayServicesAvailable(Context
context)
This method is deprecated. Use
GoogleApiAvailability.isGooglePlayServicesAvailable(Context)
instead.
|
static int |
isGooglePlayServicesAvailable(Context
context, int minApkVersion)
This method is deprecated. Use
GoogleApiAvailability.isGooglePlayServicesAvailable(Context)
instead.
|
static boolean |
isUserRecoverableError(int errorCode)
This method is deprecated. Use
GoogleApiAvailability.isUserResolvableError(int) instead.
|
static boolean |
showErrorDialogFragment(int errorCode,Activity
activity, int requestCode,
DialogInterface.OnCancelListenercancelListener)
This method is deprecated. Use
GoogleApiAvailability.showErrorDialogFragment(Activity, int, int,
OnCancelListener) instead.
|
static boolean |
showErrorDialogFragment(int errorCode,Activity
activity,Fragment
fragment, int requestCode,
DialogInterface.OnCancelListenercancelListener)
|
static boolean |
showErrorDialogFragment(int errorCode,Activity
activity, int requestCode)
This method is deprecated. Use
GoogleApiAvailability.showErrorDialogFragment(Activity, int, int)
instead.
|
static void |
showErrorNotification(int errorCode,Context
context)
This method is deprecated. Use
GoogleApiAvailability.showErrorNotification(Context, int)
instead.
|
Inherited Method Summary
Constants
public static finalString GMS_ERROR_DIALOG
public static finalString GOOGLE_PLAY_SERVICES_PACKAGE
This constant is deprecated.
Use
GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE
instead.
Package name for Google Play services.
public static finalString GOOGLE_PLAY_STORE_PACKAGE
Package name for Google Play Store.
Fields
public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE
This field is deprecated.
Use
GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE
instead.
Google Play services client library version (declared in library's AndroidManifest.xml android:versionCode).
Public Methods
public staticDialoggetErrorDialog(int errorCode, Activity activity, int requestCode)
This method is deprecated.
Use
GoogleApiAvailability.getErrorDialog(Activity, int, int)
instead.
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
ConnectionResult.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 staticDialoggetErrorDialog(int errorCode, Activity activity, int requestCode,DialogInterface.OnCancelListener cancelListener)
This method is deprecated.
Use
GoogleApiAvailability.getErrorDialog(Activity, int, int, OnCancelListener)
instead.
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
ConnectionResult.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 staticPendingIntent getErrorPendingIntent(int errorCode,Contextcontext, int requestCode)
This method is deprecated.
Use
GoogleApiAvailability.getErrorResolutionPendingIntent(Context,
ConnectionResult)
instead.
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
ConnectionResult.SUCCESS
then null is returned. |
---|---|
context | parent context for creating the PendingIntent. |
requestCode | The requestCode given when calling startActivityForResult. |
public staticStringgetErrorString(int errorCode)
This method is deprecated.
Use
GoogleApiAvailability.getErrorString(int)
instead.
Returns a human-readable string of the error code returned from
isGooglePlayServicesAvailable(Context)
.
public staticStringgetOpenSourceSoftwareLicenseInfo(Context context)
This method is deprecated.
This license information is displayed in Settings > Google > Open Source on any
device running Google Play services. Applications do not need to display this license
text, and this method will be removed in a future version of Google Play services.
public staticContext 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 staticResources 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 intisGooglePlayServicesAvailable(Context context)
This method is deprecated.
Use
GoogleApiAvailability.isGooglePlayServicesAvailable(Context)
instead.
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
public static intisGooglePlayServicesAvailable(Contextcontext, int minApkVersion)
This method is deprecated.
Use
GoogleApiAvailability.isGooglePlayServicesAvailable(Context)
instead.
public static booleanisUserRecoverableError(int errorCode)
This method is deprecated.
Use
GoogleApiAvailability.isUserResolvableError(int)
instead.
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
viaGoogleApiClient.OnConnectionFailedListener#onConnectionFailed |
---|
Returns
- true if the error is recoverable with
getErrorDialog(int, Activity, int)
public static booleanshowErrorDialogFragment(int errorCode,Activityactivity, int requestCode,DialogInterface.OnCancelListener cancelListener)
This method is deprecated.
Use
GoogleApiAvailability.showErrorDialogFragment(Activity, int, int,
OnCancelListener)
instead.
Display a DialogFragment for an error code returned by
isGooglePlayServicesAvailable(Context)
.
Parameters
errorCode | error code returned by
isGooglePlayServicesAvailable(Context) call. If errorCode is
ConnectionResult.SUCCESS
then this does nothing |
---|---|
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. |
Returns
- true if the dialog is shown, false otherwise.
Throws
RuntimeException | if API level is below 11 andactivity is not aFragmentActivity . |
---|
public static booleanshowErrorDialogFragment(int errorCode,Activityactivity, Fragment fragment, int requestCode,DialogInterface.OnCancelListener cancelListener)
public static booleanshowErrorDialogFragment(int errorCode,Activityactivity, int requestCode)
This method is deprecated.
Use
GoogleApiAvailability.showErrorDialogFragment(Activity, int, int)
instead.
Display a DialogFragment for an error code returned by
isGooglePlayServicesAvailable(Context)
.
Parameters
errorCode | error code returned by
isGooglePlayServicesAvailable(Context) call. If errorCode is
ConnectionResult.SUCCESS
then this does nothing. |
---|---|
activity | parent activity for creating the dialog, also used for identifying language to display dialog in. |
requestCode | The requestCode given when calling startActivityForResult. |
Returns
- true if the dialog is shown, false otherwise
Throws
RuntimeException | if API level is below 11 andactivity is not aFragmentActivity . |
---|
public static voidshowErrorNotification(int errorCode, Context context)
This method is deprecated.
Use
GoogleApiAvailability.showErrorNotification(Context, int)
instead.
Displays a notification relevant to the provided error code. This method is similar
to
getErrorDialog(int, android.app.Activity, int)
,but is provided for
background tasks that cannot or shouldn't display dialogs.
Parameters
errorCode | error code returned by
isGooglePlayServicesAvailable(Context) call. If errorCode is
ConnectionResult.SUCCESS
then null is returned. |
---|---|
context | used for identifying language to display dialog in as well as accessing the
NotificationManager . |