ConnectionResult

public final class ConnectionResult extends Object
implements Parcelable

Contains all possible error codes for when a client fails to connect to Google Play services. These error codes are used by GoogleApiClient.OnConnectionFailedListener.

Constant Summary

int API_DISABLED The API being requested is disabled on this device for this application.
int API_DISABLED_FOR_CONNECTION The API being requested is disabled for this connection attempt, but may work for other connections.
int API_UNAVAILABLE One of the API components you attempted to connect to is not available.
int CANCELED The connection was canceled.
int DEVELOPER_ERROR The application is misconfigured.
int DRIVE_EXTERNAL_STORAGE_REQUIRED This constant is deprecated. External storage is no longer required.
int INTERNAL_ERROR An internal error occurred.
int INTERRUPTED An interrupt occurred while waiting for the connection complete.
int INVALID_ACCOUNT The client attempted to connect to the service with an invalid account name specified.
int LICENSE_CHECK_FAILED The application is not licensed to the user.
int NETWORK_ERROR A network error occurred.
int RESOLUTION_ACTIVITY_NOT_FOUND There was a user-resolvable issue connecting to Google Play services, but when attempting to start the resolution, the activity was not found.
int RESOLUTION_REQUIRED Completing the connection requires some form of resolution.
int RESTRICTED_PROFILE The current user profile is restricted and cannot use authenticated features.
int SERVICE_DISABLED The installed version of Google Play services has been disabled on this device.
int SERVICE_INVALID The version of the Google Play services installed on this device is not authentic.
int SERVICE_MISSING Google Play services is missing on this device.
int SERVICE_MISSING_PERMISSION Google Play service doesn't have one or more required permissions.
int SERVICE_UPDATING Google Play service is currently being updated on this device.
int SERVICE_VERSION_UPDATE_REQUIRED The installed version of Google Play services is out of date.
int SIGN_IN_FAILED The client attempted to connect to the service but the user is not signed in.
int SIGN_IN_REQUIRED The client attempted to connect to the service but the user is not signed in.
int SUCCESS The connection was successful.
int TIMEOUT The timeout was exceeded while waiting for the connection to complete.

Inherited Constant Summary

Field Summary

public static final Creator<ConnectionResult> CREATOR

Public Constructor Summary

ConnectionResult(int statusCode)
Creates a connection result.
ConnectionResult(int statusCode, PendingIntent pendingIntent)
Creates a connection result.
ConnectionResult(int statusCode, PendingIntent pendingIntent, String message)
Creates a connection result.

Public Method Summary

boolean
int
getErrorCode()
Indicates the type of error that interrupted connection.
String
getErrorMessage()
Returns an error message for connection result.
PendingIntent
getResolution()
A pending intent to resolve the connection failure.
boolean
hasResolution()
Returns true if calling startResolutionForResult(Activity, int) will start any intents requiring user interaction.
int
boolean
isSuccess()
Returns true if the connection was successful.
void
startResolutionForResult(Activity activity, int requestCode)
Resolves an error by starting any intents requiring user interaction.
String
void
writeToParcel(Parcel out, int flags)

Inherited Method Summary

Constants

public static final int API_DISABLED

The API being requested is disabled on this device for this application. Trying again at a later time may succeed.

Constant Value: 23

public static final int API_DISABLED_FOR_CONNECTION

The API being requested is disabled for this connection attempt, but may work for other connections.

Constant Value: 24

public static final int API_UNAVAILABLE

One of the API components you attempted to connect to is not available. The API will not work on this device or for your app or for this particular account, and updating Google Play services will not likely solve the problem.

Constant Value: 16

public static final int CANCELED

The connection was canceled. This is returned in two situations:

Constant Value: 13

public static final int DEVELOPER_ERROR

The application is misconfigured. This error is not recoverable and will be treated as fatal. The developer should look at the logs after this to determine more actionable information.

Constant Value: 10

public static final int DRIVE_EXTERNAL_STORAGE_REQUIRED

This constant is deprecated.
External storage is no longer required.

The Drive API requires external storage (such as an SD card), but no external storage is mounted. This error is recoverable if the user installs external storage (if none is present) and ensures that it is mounted (which may involve disabling USB storage mode, formatting the storage, or other initialization as required by the device).

This error should never be returned on a device with emulated external storage. On devices with emulated external storage, the emulated "external storage" is always present regardless of whether the device also has removable storage.

Constant Value: 1500

public static final int INTERNAL_ERROR

An internal error occurred. Retrying should resolve the problem.

Constant Value: 8

public static final int INTERRUPTED

An interrupt occurred while waiting for the connection complete. Only returned by GoogleApiClient.blockingConnect().

Constant Value: 15

public static final int INVALID_ACCOUNT

The client attempted to connect to the service with an invalid account name specified.

Constant Value: 5

public static final int LICENSE_CHECK_FAILED

The application is not licensed to the user. This error is not recoverable and will be treated as fatal.

Constant Value: 11

public static final int NETWORK_ERROR

A network error occurred. Retrying should resolve the problem.

Constant Value: 7

public static final int RESOLUTION_ACTIVITY_NOT_FOUND

There was a user-resolvable issue connecting to Google Play services, but when attempting to start the resolution, the activity was not found.

This can occur when attempting to resolve issues connecing to Google Play services on emulators with Google APIs but not Google Play Store.

Constant Value: 22

public static final int RESOLUTION_REQUIRED

Completing the connection requires some form of resolution. A resolution will be available to be started with startResolutionForResult(Activity, int). If the result returned is Activity.RESULT_OK, then further attempts to connect should either complete or continue on to the next issue that needs to be resolved.

Constant Value: 6

public static final int RESTRICTED_PROFILE

The current user profile is restricted and cannot use authenticated features. (Jelly Bean MR2+ Restricted Profiles for Android tablets)

Constant Value: 20

public static final int SERVICE_DISABLED

The installed version of Google Play services has been disabled on this device. The calling activity should pass this error code to GoogleApiAvailability.getErrorDialog(Activity, int, int) to get a localized error dialog that will resolve the error when shown.

Constant Value: 3

public static final int SERVICE_INVALID

The version of the Google Play services installed on this device is not authentic.

Constant Value: 9

public static final int SERVICE_MISSING

Google Play services is missing on this device. The calling activity should pass this error code to GoogleApiAvailability.getErrorDialog(Activity, int, int) to get a localized error dialog that will resolve the error when shown.

Constant Value: 1

public static final int SERVICE_MISSING_PERMISSION

Google Play service doesn't have one or more required permissions. The client may call startResolutionForResult(Activity, int) to prompt the user to fix the issue. After activity returns with Activity.RESULT_OK further attempts to connect should succeed.

Constant Value: 19

public static final int SERVICE_UPDATING

Google Play service is currently being updated on this device.

Constant Value: 18

public static final int SERVICE_VERSION_UPDATE_REQUIRED

The installed version of Google Play services is out of date. The calling activity should pass this error code to GoogleApiAvailability.getErrorDialog(Activity, int, int) to get a localized error dialog that will resolve the error when shown.

Constant Value: 2

public static final int SIGN_IN_FAILED

The client attempted to connect to the service but the user is not signed in. An error may have occurred when signing in the user and the error can not be recovered with any user interaction. Alternately, the API may have been requested with GoogleApiClient.Builder.addApiIfAvailable(Api , Scope...) and it may be the case that no required APIs needed authentication, so authentication did not occur.

When seeing this error code,there is no resolution for the sign-in failure.

Constant Value: 17

public static final int SIGN_IN_REQUIRED

The client attempted to connect to the service but the user is not signed in. The client may choose to continue without using the API. Alternately, if hasResolution() returns true the client may call startResolutionForResult(Activity, int) to prompt the user to sign in. After the sign in activity returns with Activity.RESULT_OK further attempts should succeed.

Constant Value: 4

public static final int SUCCESS

The connection was successful.

Constant Value: 0

public static final int TIMEOUT

The timeout was exceeded while waiting for the connection to complete. Only returned by GoogleApiClient.blockingConnect().

Constant Value: 14

Fields

public static final Creator<ConnectionResult> CREATOR

Public Constructors

public ConnectionResult (int statusCode)

Creates a connection result.

Parameters
statusCode The status code.

public ConnectionResult (int statusCode, PendingIntent pendingIntent)

Creates a connection result.

Parameters
statusCode The status code.
pendingIntent A pending intent that will resolve the issue when started, or null.

public ConnectionResult (int statusCode, PendingIntent pendingIntent, String message)

Creates a connection result.

Parameters
statusCode The status code.
pendingIntent A pending intent that will resolve the issue when started, or null.
message An additional error message for the connection result, or null.

Public Methods

public boolean equals (Object o)

public int getErrorCode ()

Indicates the type of error that interrupted connection.

Returns
  • the error code, or SUCCESS if no error occurred.

public String getErrorMessage ()

Returns an error message for connection result.

Returns
  • the message.

public PendingIntent getResolution ()

A pending intent to resolve the connection failure. This intent can be started with Activity.startIntentSenderForResult(IntentSender, int, Intent, int, int, int) to present UI to solve the issue.

Returns
  • The pending intent to resolve the connection failure.

public boolean hasResolution ()

Returns true if calling startResolutionForResult(Activity, int) will start any intents requiring user interaction.

Returns
  • true if there is a resolution that can be started.

public int hashCode ()

public boolean isSuccess ()

Returns true if the connection was successful.

Returns
  • true if the connection was successful, false if there was an error.

public void startResolutionForResult (Activity activity, int requestCode)

Resolves an error by starting any intents requiring user interaction. See SIGN_IN_REQUIRED, and RESOLUTION_REQUIRED.

Parameters
activity An Activity context to use to resolve the issue. The activity's onActivityResult method will be invoked after the user is done. If the resultCode is Activity.RESULT_OK, the application should try to connect again.
requestCode The request code to pass to onActivityResult.
Throws
IntentSender.SendIntentException If the resolution intent has been canceled or is no longer able to execute the request.

public String toString ()

public void writeToParcel (Parcel out, int flags)