diff --git a/docs/html/gcm_navtree_data.js b/docs/html/gcm_navtree_data.js new file mode 100644 index 0000000000000000000000000000000000000000..d3af043a36ea7e260ea2976c66f58403290fdd87 --- /dev/null +++ b/docs/html/gcm_navtree_data.js @@ -0,0 +1,9 @@ +var GCM_NAVTREE_DATA = +[ [ "com.google.android.gcm", "reference/com/google/android/gcm/package-summary.html", [ [ "Classes", null, [ [ "GCMBaseIntentService", "reference/com/google/android/gcm/GCMBaseIntentService.html", null, null ], [ "GCMBroadcastReceiver", "reference/com/google/android/gcm/GCMBroadcastReceiver.html", null, null ], [ "GCMConstants", "reference/com/google/android/gcm/GCMConstants.html", null, null ], [ "GCMRegistrar", "reference/com/google/android/gcm/GCMRegistrar.html", null, null ] ] +, null ] ] +, null ], [ "com.google.android.gcm.server", "reference/com/google/android/gcm/server/package-summary.html", [ [ "Classes", null, [ [ "Constants", "reference/com/google/android/gcm/server/Constants.html", null, null ], [ "Message", "reference/com/google/android/gcm/server/Message.html", [ [ "Builder", "reference/com/google/android/gcm/server/Message.Builder.html", null, null ] ], null ], [ "MulticastResult", "reference/com/google/android/gcm/server/MulticastResult.html", null, null ], [ "Result", "reference/com/google/android/gcm/server/Result.html", [ [ "Builder", "reference/com/google/android/gcm/server/Result.Builder.html", null, null ] ], null ], [ "Sender", "reference/com/google/android/gcm/server/Sender.html", null, null ] ] +, null ], [ "Exceptions", null, [ [ "InvalidRequestException", "reference/com/google/android/gcm/server/InvalidRequestException.html", null, null ] ] +, null ] ] +, null ] ] + +; diff --git a/docs/html/gms_navtree_data.js b/docs/html/gms_navtree_data.js new file mode 100644 index 0000000000000000000000000000000000000000..26bb8ea3a9f6a237fe79dd16be8b22097a4d8633 --- /dev/null +++ b/docs/html/gms_navtree_data.js @@ -0,0 +1,24 @@ +var GMS_NAVTREE_DATA = +[ [ "com.google.android.gms", "reference/com/google/android/gms/package-summary.html", [ [ "Classes", null, [ [ "R", "reference/com/google/android/gms/R.html", [ [ "attr", "reference/com/google/android/gms/R.attr.html", null, null ], [ "id", "reference/com/google/android/gms/R.id.html", null, null ], [ "string", "reference/com/google/android/gms/R.string.html", null, null ], [ "styleable", "reference/com/google/android/gms/R.styleable.html", null, null ] ], null ] ] +, null ] ] +, null ], [ "com.google.android.gms.auth", "reference/com/google/android/gms/auth/package-summary.html", [ [ "Classes", null, [ [ "GoogleAuthUtil", "reference/com/google/android/gms/auth/GoogleAuthUtil.html", null, null ] ] +, null ], [ "Exceptions", null, [ [ "GoogleAuthException", "reference/com/google/android/gms/auth/GoogleAuthException.html", null, null ], [ "GooglePlayServicesAvailabilityException", "reference/com/google/android/gms/auth/GooglePlayServicesAvailabilityException.html", null, null ], [ "UserRecoverableAuthException", "reference/com/google/android/gms/auth/UserRecoverableAuthException.html", null, null ], [ "UserRecoverableNotifiedException", "reference/com/google/android/gms/auth/UserRecoverableNotifiedException.html", null, null ] ] +, null ] ] +, null ], [ "com.google.android.gms.common", "reference/com/google/android/gms/common/package-summary.html", [ [ "Interfaces", null, [ [ "GooglePlayServicesClient", "reference/com/google/android/gms/common/GooglePlayServicesClient.html", [ [ "ConnectionCallbacks", "reference/com/google/android/gms/common/GooglePlayServicesClient.ConnectionCallbacks.html", null, null ], [ "OnConnectionFailedListener", "reference/com/google/android/gms/common/GooglePlayServicesClient.OnConnectionFailedListener.html", null, null ] ], null ] ] +, null ], [ "Classes", null, [ [ "AccountPicker", "reference/com/google/android/gms/common/AccountPicker.html", null, null ], [ "ConnectionResult", "reference/com/google/android/gms/common/ConnectionResult.html", null, null ], [ "GooglePlayServicesUtil", "reference/com/google/android/gms/common/GooglePlayServicesUtil.html", null, null ], [ "Scopes", "reference/com/google/android/gms/common/Scopes.html", null, null ] ] +, null ], [ "Exceptions", null, [ [ "GooglePlayServicesNotAvailableException", "reference/com/google/android/gms/common/GooglePlayServicesNotAvailableException.html", null, null ] ] +, null ] ] +, null ], [ "com.google.android.gms.maps", "reference/com/google/android/gms/maps/package-summary.html", [ [ "Interfaces", null, [ [ "LocationSource", "reference/com/google/android/gms/maps/LocationSource.html", [ [ "OnLocationChangedListener", "reference/com/google/android/gms/maps/LocationSource.OnLocationChangedListener.html", null, null ] ], null ] ] +, null ], [ "Classes", null, [ [ "CameraUpdate", "reference/com/google/android/gms/maps/CameraUpdate.html", null, null ], [ "CameraUpdateFactory", "reference/com/google/android/gms/maps/CameraUpdateFactory.html", null, null ], [ "GoogleMap", "reference/com/google/android/gms/maps/GoogleMap.html", [ [ "CancelableCallback", "reference/com/google/android/gms/maps/CancelableCallback.html", null, null ], [ "InfoWindowAdapter", "reference/com/google/android/gms/maps/GoogleMap.InfoWindowAdapter.html", null, null ], [ "OnCameraChangeListener", "reference/com/google/android/gms/maps/GoogleMap.OnCameraChangeListener.html", null, null ], [ "OnInfoWindowClickListener", "reference/com/google/android/gms/maps/GoogleMap.OnInfoWindowClickListener.html", null, null ], [ "OnMapClickListener", "reference/com/google/android/gms/maps/GoogleMap.OnMapClickListener.html", null, null ], [ "OnMapLongClickListener", "reference/com/google/android/gms/maps/GoogleMap.OnMapLongClickListener.html", null, null ], [ "OnMarkerClickListener", "reference/com/google/android/gms/maps/GoogleMap.OnMarkerClickListener.html", null, null ], [ "OnMarkerDragListener", "reference/com/google/android/gms/maps/GoogleMap.OnMarkerDragListener.html", null, null ] ], null ], [ "GoogleMapOptions", "reference/com/google/android/gms/maps/GoogleMapOptions.html", null, null ], [ "MapFragment", "reference/com/google/android/gms/maps/MapFragment.html", null, null ], [ "MapsInitializer", "reference/com/google/android/gms/maps/MapsInitializer.html", null, null ], [ "MapView", "reference/com/google/android/gms/maps/MapView.html", null, null ], [ "Projection", "reference/com/google/android/gms/maps/Projection.html", null, null ], [ "SupportMapFragment", "reference/com/google/android/gms/maps/SupportMapFragment.html", null, null ], [ "UiSettings", "reference/com/google/android/gms/maps/UiSettings.html", null, null ] ] +, null ] ] +, null ], [ "com.google.android.gms.maps.model", "reference/com/google/android/gms/maps/model/package-summary.html", [ [ "Interfaces", null, [ [ "TileProvider", "reference/com/google/android/gms/maps/model/TileProvider.html", null, null ] ] +, null ], [ "Classes", null, [ [ "BitmapDescriptor", "reference/com/google/android/gms/maps/model/BitmapDescriptor.html", null, null ], [ "BitmapDescriptorFactory", "reference/com/google/android/gms/maps/model/BitmapDescriptorFactory.html", null, null ], [ "CameraPosition", "reference/com/google/android/gms/maps/model/CameraPosition.html", [ [ "Builder", "reference/com/google/android/gms/maps/model/CameraPosition.Builder.html", null, null ]], null ], [ "GroundOverlay", "reference/com/google/android/gms/maps/model/GroundOverlay.html", null, null ], [ "GroundOverlayOptions", "reference/com/google/android/gms/maps/model/GroundOverlayOptions.html", null, null ], [ "LatLng", "reference/com/google/android/gms/maps/model/LatLng.html", null, null ], [ "LatLngBounds", "reference/com/google/android/gms/maps/model/LatLngBounds.html", [ [ "Builder", "reference/com/google/android/gms/maps/model/LatLngBounds.Builder.html", null, null ] ], null ], [ "Marker", "reference/com/google/android/gms/maps/model/Marker.html", null, null ], [ "MarkerOptions", "reference/com/google/android/gms/maps/model/MarkerOptions.html", null, null ], [ "Polygon", "reference/com/google/android/gms/maps/model/Polygon.html", null, null ], [ "PolygonOptions", "reference/com/google/android/gms/maps/model/PolygonOptions.html", null, null ], [ "Polyline", "reference/com/google/android/gms/maps/model/Polyline.html", null, null ], [ "PolylineOptions", "reference/com/google/android/gms/maps/model/PolylineOptions.html", null, null ], [ "Tile", "reference/com/google/android/gms/maps/model/Tile.html", null, null ], [ "TileOverlay", "reference/com/google/android/gms/maps/model/TileOverlay.html", null, null ], [ "TileOverlayOptions", "reference/com/google/android/gms/maps/model/TileOverlayOptions.html", null, null ], [ "UrlTileProvider", "reference/com/google/android/gms/maps/model/UrlTileProvider.html", null, null ], [ "VisibleRegion", "reference/com/google/android/gms/maps/model/VisibleRegion.html", null, null ] ] +, null ], [ "Exceptions", null, [ [ "RuntimeRemoteException", "reference/com/google/android/gms/maps/model/RuntimeRemoteException.html", null, null ] ] +, null ] ] +, null ], [ "com.google.android.gms.panorama", "reference/com/google/android/gms/panorama/package-summary.html", [ [ "Classes", null, [ [ "PanoramaClient", "reference/com/google/android/gms/panorama/PanoramaClient.html", [ [ "OnPanoramaInfoLoadedListener", "reference/com/google/android/gms/panorama/PanoramaClient.OnPanoramaInfoLoadedListener.html", null, null ] ], null ] ] +, null ] ] +, null ], [ "com.google.android.gms.plus", "reference/com/google/android/gms/plus/package-summary.html", [ [ "Classes", null, [ [ "GooglePlusUtil", "reference/com/google/android/gms/plus/GooglePlusUtil.html", null, null ], [ "PlusClient", "reference/com/google/android/gms/plus/PlusClient.html", null, null ], [ "PlusOneButton", "reference/com/google/android/gms/plus/PlusOneButton.html", [ [ "OnPlusOneClickListener", "reference/com/google/android/gms/plus/PlusOneButton.OnPlusOneClickListener.html", null, null ] ], null ], [ "PlusShare", "reference/com/google/android/gms/plus/PlusShare.html", [ [ "Builder", "reference/com/google/android/gms/plus/PlusShare.Builder.html", null, null ] ], null ], [ "PlusSignInButton", "reference/com/google/android/gms/plus/PlusSignInButton.html", null, null ] ] +, null ] ] +, null ] ] + +; diff --git a/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html b/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html new file mode 100644 index 0000000000000000000000000000000000000000..27348d1936171752fcdb161bece9ea0cedb8fa8e --- /dev/null +++ b/docs/html/reference/com/google/android/gcm/GCMBaseIntentService.html @@ -0,0 +1,5614 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +java.lang.Object | +|||||
↳ | + +android.content.Context | +||||
+ + | ↳ | + +android.content.ContextWrapper | +|||
+ + | + + | ↳ | + +android.app.Service | +||
+ + | + + | + + | ↳ | + +android.app.IntentService | +|
+ + | + + | + + | + + | ↳ | + +com.google.android.gcm.GCMBaseIntentService | +
Skeleton for application-specific IntentService
s responsible for
+ handling communication from Google Cloud Messaging service.
+
+ The abstract methods in this class are called from its worker thread, and + hence should run in a limited amount of time. If they execute long + operations, they should spawn new threads, otherwise the worker thread will + be blocked. +
+ Subclasses must provide a public no-arg constructor. +
+ + + + + +Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | +TAG | +Old TAG used for logging. | +
+ [Expand]
+ Inherited Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+ From class
+android.app.Service
+
+
+
+
+
+
+
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+ From class
+android.content.Context
+
+
+
+
+
+
+
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+ From interface
+android.content.ComponentCallbacks2
+
+
+
+
+
+
+
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor that does not set a sender id, useful when the sender id
+ is context-specific.
+
+ | |||||||||||
Constructor used when the sender id(s) is fixed.
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the sender ids.
+
+ | |||||||||||
Called when the GCM server tells pending messages have been deleted
+ because the device was idle.
+
+ | |||||||||||
Called on registration or unregistration error.
+
+ | |||||||||||
Called when a cloud message has been received.
+
+ | |||||||||||
Called on a registration error that could be retried.
+
+ | |||||||||||
Called after a device has been registered.
+
+ | |||||||||||
Called after a device has been unregistered.
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ android.app.IntentService
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+From class
+
+ android.app.Service
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+From class
+
+ android.content.ContextWrapper
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+From class
+
+ android.content.Context
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+From interface
+
+ android.content.ComponentCallbacks
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+From interface
+
+ android.content.ComponentCallbacks2
+
+
+
+
+
+
+
+ |
Old TAG used for logging. Marked as deprecated since it should have + been private at first place. +
Constructor that does not set a sender id, useful when the sender id + is context-specific. +
+ When using this constructor, the subclass must
+ override getSenderIds(Context)
, otherwise methods such as
+ onHandleIntent(Intent)
will throw an
+ IllegalStateException
on runtime.
+
Constructor used when the sender id(s) is fixed. +
Gets the sender ids. + +
By default, it returns the sender ids passed in the constructor, but + it could be overridden to provide a dynamic sender id.
IllegalStateException + | if sender id was not set on constructor. + | +
---|
Called when the GCM server tells pending messages have been deleted + because the device was idle.
context + | application's context. | +
---|---|
total + | total number of collapsed messages + | +
Called on registration or unregistration error.
context + | application's context. | +
---|---|
errorId + | error id returned by the GCM service. + | +
Called when a cloud message has been received.
context + | application's context. | +
---|---|
intent + | intent containing the message payload as extras. + | +
Called on a registration error that could be retried. + +
By default, it does nothing and returns true, but could be + overridden to change that behavior and/or display the error.
context + | application's context. | +
---|---|
errorId + | error id returned by the GCM service. | +
Called after a device has been registered.
context + | application's context. | +
---|---|
registrationId + | the registration id returned by the GCM service. + | +
Called after a device has been unregistered.
context + | application's context. + | +
---|---|
registrationId + | the registration id that was previously registered. | +
+ About Android | + Legal | + Support +
+java.lang.Object | +||
↳ | + +android.content.BroadcastReceiver | +|
+ + | ↳ | + +com.google.android.gcm.GCMBroadcastReceiver | +
BroadcastReceiver
that receives GCM messages and delivers them to
+ an application-specific GCMBaseIntentService
subclass.
+
+ By default, the GCMBaseIntentService
class belongs to the application
+ main package and is named
+ DEFAULT_INTENT_SERVICE_CLASS_NAME
. To use a new class,
+ the getGCMIntentServiceClassName(Context)
must be overridden.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the class name of the intent service that will handle GCM messages.
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ android.content.BroadcastReceiver
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Gets the class name of the intent service that will handle GCM messages. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.GCMConstants | +
Constants used by the GCM library. +
+ + + + + +Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | +DEFAULT_INTENT_SERVICE_CLASS_NAME | ++ | |||||||||
String | +ERROR_ACCOUNT_MISSING | +There is no Google account on the phone. | +|||||||||
String | +ERROR_AUTHENTICATION_FAILED | +Bad password. | +|||||||||
String | +ERROR_INVALID_PARAMETERS | +The request sent by the phone does not contain the expected parameters. | +|||||||||
String | +ERROR_INVALID_SENDER | +The sender account is not recognized. | +|||||||||
String | +ERROR_PHONE_REGISTRATION_ERROR | +Incorrect phone registration with Google. | +|||||||||
String | +ERROR_SERVICE_NOT_AVAILABLE | +The device can't read the response, or there was a 500/503 from the + server that can be retried later. | +|||||||||
String | +EXTRA_APPLICATION_PENDING_INTENT | +Extra used on {@value #INTENT_TO_GCM_REGISTRATION} to get the + application info. | +|||||||||
String | +EXTRA_ERROR | +Extra used on {@value #INTENT_FROM_GCM_REGISTRATION_CALLBACK} to indicate + an error when the registration fails. | +|||||||||
String | +EXTRA_FROM | +Extra used on {@value #INTENT_FROM_GCM_MESSAGE} to indicate which + sender (Google API project id) sent the message. | +|||||||||
String | +EXTRA_REGISTRATION_ID | +Extra used on {@value #INTENT_FROM_GCM_REGISTRATION_CALLBACK} to indicate + the registration id when the registration succeeds. | +|||||||||
String | +EXTRA_SENDER | +Extra used on {@value #INTENT_TO_GCM_REGISTRATION} to indicate which + senders (Google API project ids) can send messages to the application. | +|||||||||
String | +EXTRA_SPECIAL_MESSAGE | +Type of message present in the {@value #INTENT_FROM_GCM_MESSAGE} intent. | +|||||||||
String | +EXTRA_TOTAL_DELETED | +Number of messages deleted by the server because the device was idle. | +|||||||||
String | +EXTRA_UNREGISTERED | +Extra used on {@value #INTENT_FROM_GCM_REGISTRATION_CALLBACK} to indicate + that the application has been unregistered. | +|||||||||
String | +INTENT_FROM_GCM_LIBRARY_RETRY | +Intent used by the GCM library to indicate that the registration call + should be retried. | +|||||||||
String | +INTENT_FROM_GCM_MESSAGE | +Intent sent by GCM containing a message. | +|||||||||
String | +INTENT_FROM_GCM_REGISTRATION_CALLBACK | +Intent sent by GCM indicating with the result of a registration request. | +|||||||||
String | +INTENT_TO_GCM_REGISTRATION | +Intent sent to GCM to register the application. | +|||||||||
String | +INTENT_TO_GCM_UNREGISTRATION | +Intent sent to GCM to unregister the application. | +|||||||||
String | +PERMISSION_GCM_INTENTS | +Permission necessary to receive GCM intents. | +|||||||||
String | +VALUE_DELETED_MESSAGES | +Special message indicating the server deleted the pending messages. | +
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
There is no Google account on the phone. The application should ask the + user to open the account manager and add a Google account. +
Bad password. The application should ask the user to enter his/her + password, and let user retry manually later. Fix on the device side. +
The request sent by the phone does not contain the expected parameters. + This phone doesn't currently support GCM. +
The sender account is not recognized. Fix on the device side. +
Incorrect phone registration with Google. This phone doesn't currently + support GCM. +
The device can't read the response, or there was a 500/503 from the + server that can be retried later. The application should use exponential + back off and retry. +
Extra used on {@value #INTENT_TO_GCM_REGISTRATION} to get the + application info. +
Extra used on {@value #INTENT_FROM_GCM_REGISTRATION_CALLBACK} to indicate + an error when the registration fails. See constants starting with ERROR_ + for possible values. +
Extra used on {@value #INTENT_FROM_GCM_MESSAGE} to indicate which + sender (Google API project id) sent the message. +
Extra used on {@value #INTENT_FROM_GCM_REGISTRATION_CALLBACK} to indicate + the registration id when the registration succeeds. +
Extra used on {@value #INTENT_TO_GCM_REGISTRATION} to indicate which + senders (Google API project ids) can send messages to the application. +
Type of message present in the {@value #INTENT_FROM_GCM_MESSAGE} intent. + This extra is only set for special messages sent from GCM, not for + messages originated from the application. +
Number of messages deleted by the server because the device was idle. + Present only on messages of special type + {@value #VALUE_DELETED_MESSAGES} +
Extra used on {@value #INTENT_FROM_GCM_REGISTRATION_CALLBACK} to indicate + that the application has been unregistered. +
Intent used by the GCM library to indicate that the registration call + should be retried. +
Intent sent by GCM containing a message. +
Intent sent by GCM indicating with the result of a registration request. +
Intent sent to GCM to register the application. +
Intent sent to GCM to unregister the application. +
Permission necessary to receive GCM intents. +
Special message indicating the server deleted the pending messages. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.GCMRegistrar | +
Utilities for device registration. +
+ Note: this class uses a private SharedPreferences
+ object to keep track of the registration token.
+
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
long | +DEFAULT_ON_SERVER_LIFESPAN_MS | +Default lifespan (7 days) of the isRegisteredOnServer(Context)
+ flag until it is considered expired. |
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Checks if the device has the proper dependencies installed.
+
+ | |||||||||||
Checks that the application manifest is properly configured.
+
+ | |||||||||||
Gets how long (in milliseconds) the
+
+ isRegistered(Context)
+ property is valid. | |||||||||||
Gets the current registration id for application on GCM service.
+
+ | |||||||||||
Checks whether the application was successfully registered on GCM
+ service.
+
+ | |||||||||||
Checks whether the device was successfully registered in the server side,
+ as set by
+
+ setRegisteredOnServer(Context, boolean) . | |||||||||||
Clear internal resources.
+
+ | |||||||||||
Initiate messaging registration for the current application.
+
+ | |||||||||||
Sets how long (in milliseconds) the
+
+ isRegistered(Context)
+ flag is valid. | |||||||||||
Sets whether the device was successfully registered in the server side.
+
+ | |||||||||||
Unregister the application.
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Default lifespan (7 days) of the isRegisteredOnServer(Context)
+ flag until it is considered expired.
+
Checks if the device has the proper dependencies installed. +
+ This method should be called when the application starts to verify that + the device supports GCM.
context + | application context. | +
---|
UnsupportedOperationException + | if the device does not support GCM. + | +
---|
Checks that the application manifest is properly configured. +
+ A proper configuration means: +
PACKAGE_NAME.permission.C2D_MESSAGE
.
+ BroadcastReceiver
with category
+ PACKAGE_NAME
.
+ BroadcastReceiver
(s) uses the
+ {@value com.google.android.gcm.GCMConstants#PERMISSION_GCM_INTENTS}
+ permission.
+ BroadcastReceiver
(s) handles the 2 GCM intents
+ ({@value com.google.android.gcm.GCMConstants#INTENT_FROM_GCM_MESSAGE}
+ and
+ {@value com.google.android.gcm.GCMConstants#INTENT_FROM_GCM_REGISTRATION_CALLBACK}).
+ PACKAGE_NAME
is the application package.
+ + This method should be used during development time to verify that the + manifest is properly set up, but it doesn't need to be called once the + application is deployed to the users' devices.
context + | application context. | +
---|
IllegalStateException + | if any of the conditions above is not met. + | +
---|
Gets how long (in milliseconds) the isRegistered(Context)
+ property is valid.
setRegisteredOnServer(Context, boolean)
or
+ DEFAULT_ON_SERVER_LIFESPAN_MS
if not set.
+Gets the current registration id for application on GCM service. +
+ If result is empty, the registration has failed.
Checks whether the application was successfully registered on GCM + service. +
Checks whether the device was successfully registered in the server side,
+ as set by setRegisteredOnServer(Context, boolean)
.
+
+
To avoid the scenario where the device sends the registration to the
+ server but the server loses it, this flag has an expiration date, which
+ is DEFAULT_ON_SERVER_LIFESPAN_MS
by default (but can be changed
+ by setRegisterOnServerLifespan(Context, long)
).
+
Clear internal resources. + +
+ This method should be called by the main activity's onDestroy()
+ method.
+
Initiate messaging registration for the current application. +
+ The result will be returned as an
+ INTENT_FROM_GCM_REGISTRATION_CALLBACK
intent with
+ either a EXTRA_REGISTRATION_ID
or
+ EXTRA_ERROR
.
context + | application context. | +
---|---|
senderIds + | Google Project ID of the accounts authorized to send + messages to this application. | +
IllegalStateException + | if device does not have all GCM + dependencies installed. + | +
---|
Sets how long (in milliseconds) the isRegistered(Context)
+ flag is valid.
+
Sets whether the device was successfully registered in the server side. +
Unregister the application. +
+ The result will be returned as an
+ INTENT_FROM_GCM_REGISTRATION_CALLBACK
intent with an
+ EXTRA_UNREGISTERED
extra.
+
+ About Android | + Legal | + Support +
+GCMBaseIntentService | +Skeleton for application-specific IntentService s responsible for
+ handling communication from Google Cloud Messaging service. |
+
GCMBroadcastReceiver | +BroadcastReceiver that receives GCM messages and delivers them to
+ an application-specific GCMBaseIntentService subclass. |
+
GCMConstants | +Constants used by the GCM library. | +
GCMRegistrar | +Utilities for device registration. | +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.Constants | +
Constants used on GCM service communication. +
+ + + + + +Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | +ERROR_DEVICE_QUOTA_EXCEEDED | +Too many messages sent by the sender to a specific device. | +|||||||||
String | +ERROR_INTERNAL_SERVER_ERROR | +A particular message could not be sent because the GCM servers encountered + an error. | +|||||||||
String | +ERROR_INVALID_REGISTRATION | +Bad registration_id. | +|||||||||
String | +ERROR_INVALID_TTL | +Time to Live value passed is less than zero or more than maximum. | +|||||||||
String | +ERROR_MESSAGE_TOO_BIG | +The payload of the message is too big, see the limitations. | +|||||||||
String | +ERROR_MISMATCH_SENDER_ID | +The sender_id contained in the registration_id does not match the + sender_id used to register with the GCM servers. | +|||||||||
String | +ERROR_MISSING_COLLAPSE_KEY | +Collapse key is required. | +|||||||||
String | +ERROR_MISSING_REGISTRATION | +Missing registration_id. | +|||||||||
String | +ERROR_NOT_REGISTERED | +The user has uninstalled the application or turned off notifications. | +|||||||||
String | +ERROR_QUOTA_EXCEEDED | +Too many messages sent by the sender. | +|||||||||
String | +ERROR_UNAVAILABLE | +A particular message could not be sent because the GCM servers were not + available. | +|||||||||
String | +GCM_SEND_ENDPOINT | +Endpoint for sending messages. | +|||||||||
String | +JSON_CANONICAL_IDS | +JSON-only field representing the number of messages with a canonical + registration id. | +|||||||||
String | +JSON_ERROR | +JSON-only field representing the error field of an individual request. | +|||||||||
String | +JSON_FAILURE | +JSON-only field representing the number of failed messages. | +|||||||||
String | +JSON_MESSAGE_ID | +JSON-only field sent by GCM when a message was successfully sent. | +|||||||||
String | +JSON_MULTICAST_ID | +JSON-only field representing the id of the multicast request. | +|||||||||
String | +JSON_PAYLOAD | +JSON-only field representing the payload data. | +|||||||||
String | +JSON_REGISTRATION_IDS | +JSON-only field representing the registration ids. | +|||||||||
String | +JSON_RESULTS | +JSON-only field representing the result of each individual request. | +|||||||||
String | +JSON_SUCCESS | +JSON-only field representing the number of successful messages. | +|||||||||
String | +PARAM_COLLAPSE_KEY | +HTTP parameter for collapse key. | +|||||||||
String | +PARAM_DELAY_WHILE_IDLE | +HTTP parameter for delaying the message delivery if the device is idle. | +|||||||||
String | +PARAM_DRY_RUN | +HTTP parameter for telling gcm to validate the message without actually sending it. | +|||||||||
String | +PARAM_PAYLOAD_PREFIX | +Prefix to HTTP parameter used to pass key-values in the message payload. | +|||||||||
String | +PARAM_REGISTRATION_ID | +HTTP parameter for registration id. | +|||||||||
String | +PARAM_RESTRICTED_PACKAGE_NAME | +HTTP parameter for package name that can be used to restrict message delivery by matching + against the package name used to generate the registration id. | +|||||||||
String | +PARAM_TIME_TO_LIVE | +Prefix to HTTP parameter used to set the message time-to-live. | +|||||||||
String | +TOKEN_CANONICAL_REG_ID | +Token returned by GCM when the requested registration id has a canonical + value. | +|||||||||
String | +TOKEN_ERROR | +Token returned by GCM when there was an error sending a message. | +|||||||||
String | +TOKEN_MESSAGE_ID | +Token returned by GCM when a message was successfully sent. | +
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Too many messages sent by the sender to a specific device. + Retry after a while. +
A particular message could not be sent because the GCM servers encountered + an error. Used only on JSON requests, as in plain text requests internal + errors are indicated by a 500 response. +
Bad registration_id. Sender should remove this registration_id. +
Time to Live value passed is less than zero or more than maximum. +
The payload of the message is too big, see the limitations. + Reduce the size of the message. +
The sender_id contained in the registration_id does not match the + sender_id used to register with the GCM servers. +
Collapse key is required. Include collapse key in the request. +
Missing registration_id. + Sender should always add the registration_id to the request. +
The user has uninstalled the application or turned off notifications. + Sender should stop sending messages to this device and delete the + registration_id. The client needs to re-register with the GCM servers to + receive notifications again. +
Too many messages sent by the sender. Retry after a while. +
A particular message could not be sent because the GCM servers were not + available. Used only on JSON requests, as in plain text requests + unavailability is indicated by a 503 response. +
Endpoint for sending messages. +
JSON-only field representing the number of messages with a canonical + registration id. +
JSON-only field representing the error field of an individual request. +
JSON-only field representing the number of failed messages. +
JSON-only field sent by GCM when a message was successfully sent. +
JSON-only field representing the id of the multicast request. +
JSON-only field representing the payload data. +
JSON-only field representing the registration ids. +
JSON-only field representing the result of each individual request. +
JSON-only field representing the number of successful messages. +
HTTP parameter for collapse key. +
HTTP parameter for delaying the message delivery if the device is idle. +
HTTP parameter for telling gcm to validate the message without actually sending it. +
Prefix to HTTP parameter used to pass key-values in the message payload. +
HTTP parameter for registration id. +
HTTP parameter for package name that can be used to restrict message delivery by matching + against the package name used to generate the registration id. +
Prefix to HTTP parameter used to set the message time-to-live. +
Token returned by GCM when the requested registration id has a canonical + value. +
Token returned by GCM when there was an error sending a message. +
Token returned by GCM when a message was successfully sent. +
+ About Android | + Legal | + Support +
+java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.io.IOException | +|
+ + | + + | + + | ↳ | + +com.google.android.gcm.server.InvalidRequestException | +
Exception thrown when GCM returned an error due to an invalid request. +
+ This is equivalent to GCM posts that return an HTTP error different of 200. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the error description.
+
+ | |||||||||||
Gets the HTTP Status Code.
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Throwable
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Gets the error description. +
Gets the HTTP Status Code. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.Message.Builder | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a key/value pair to the payload data.
+
+ | |||||||||||
Sets the collapseKey property.
+
+ | |||||||||||
Sets the delayWhileIdle property (default value is false).
+
+ | |||||||||||
Sets the dryRun property (default value is false).
+
+ | |||||||||||
Sets the restrictedPackageName property.
+
+ | |||||||||||
Sets the time to live, in seconds.
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Adds a key/value pair to the payload data. +
Sets the collapseKey property. +
Sets the delayWhileIdle property (default value is false). +
Sets the dryRun property (default value is false). +
Sets the restrictedPackageName property. +
Sets the time to live, in seconds. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.Message | +
GCM message. + +
+ Instances of this class are immutable and should be created using a
+ Message.Builder
. Examples:
+
+ Simplest message:
+
+ Message message = new Message.Builder().build();
+
+
+ Message with optional attributes:
+
+ Message message = new Message.Builder()
+ .collapseKey(collapseKey)
+ .timeToLive(3)
+ .delayWhileIdle(true)
+ .dryRun(true)
+ .restrictedPackageName(restrictedPackageName)
+ .build();
+
+
+ Message with optional attributes and payload data:
+
+ Message message = new Message.Builder()
+ .collapseKey(collapseKey)
+ .timeToLive(3)
+ .delayWhileIdle(true)
+ .dryRun(true)
+ .restrictedPackageName(restrictedPackageName)
+ .addData("key1", "value1")
+ .addData("key2", "value2")
+ .build();
+
+
+
+
+
+
+
+Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Message.Builder | ++ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the collapse key.
+
+ | |||||||||||
Gets the payload data, which is immutable.
+
+ | |||||||||||
Gets the restricted package name.
+
+ | |||||||||||
Gets the time to live (in seconds).
+
+ | |||||||||||
Gets the delayWhileIdle flag.
+
+ | |||||||||||
Gets the dryRun flag.
+
+ | |||||||||||
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Gets the collapse key. +
Gets the payload data, which is immutable. +
Gets the restricted package name. +
Gets the time to live (in seconds). +
Gets the delayWhileIdle flag. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.MulticastResult | +
Result of a GCM multicast message request . +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the number of successful messages that also returned a canonical
+ registration id.
+
+ | |||||||||||
Gets the number of failed messages.
+
+ | |||||||||||
Gets the multicast id.
+
+ | |||||||||||
Gets the results of each individual message, which is immutable.
+
+ | |||||||||||
Gets additional ids if more than one multicast message was sent.
+
+ | |||||||||||
Gets the number of successful messages.
+
+ | |||||||||||
Gets the total number of messages sent, regardless of the status.
+
+ | |||||||||||
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Gets the number of successful messages that also returned a canonical + registration id. +
Gets the number of failed messages. +
Gets the multicast id. +
Gets the results of each individual message, which is immutable. +
Gets additional ids if more than one multicast message was sent. +
Gets the number of successful messages. +
Gets the total number of messages sent, regardless of the status. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.Result.Builder | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.Result | +
Result of a GCM message request that returned HTTP status code 200. + +
+ If the message is successfully created, the getMessageId()
returns
+ the message id and getErrorCodeName()
returns null;
+ otherwise, getMessageId()
returns null and
+ getErrorCodeName()
returns the code of the error.
+
+
+ There are cases when a request is accept and the message successfully + created, but GCM has a canonical registration id for that device. In this + case, the server should update the registration id to avoid rejected requests + in the future. + +
+ In a nutshell, the workflow to handle a result is: +
+ - Call+ + + + + + +getMessageId()
: + - null means error, callgetErrorCodeName()
+ - non-null means the message was created: + - CallgetCanonicalRegistrationId()
+ - if it returns null, do nothing. + - otherwise, update the server datastore with the new id. +
Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Result.Builder | ++ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the canonical registration id, if any.
+
+ | |||||||||||
Gets the error code, if any.
+
+ | |||||||||||
Gets the message id, if any.
+
+ | |||||||||||
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Gets the canonical registration id, if any. +
Gets the error code, if any. +
Gets the message id, if any. +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gcm.server.Sender | +
Helper class to send messages to the GCM service using an API Key. +
+ + + + + +Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | +BACKOFF_INITIAL_DELAY | +Initial delay before first retry, without jitter. | +|||||||||
int | +MAX_BACKOFF_DELAY | +Maximum delay before a retry. | +|||||||||
String | +UTF8 | ++ |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger | ++ | ||||||||||
random | ++ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor.
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Sends a message to many devices, retrying in case of unavailability.
+
+ | |||||||||||
Sends a message to one device, retrying in case of unavailability.
+
+ | |||||||||||
Sends a message without retrying in case of service unavailability.
+
+ | |||||||||||
Sends a message without retrying in case of service unavailability.
+
+ |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a new parameter to the HTTP POST body.
+
+ | |||||||||||
Gets an
+
+ HttpURLConnection given an URL. | |||||||||||
Convenience method to convert an InputStream to a String.
+
+ | |||||||||||
Creates a
+
+ StringBuilder to be used as the body of an HTTP POST. | |||||||||||
Creates a map with just one key-value pair.
+
+ | |||||||||||
Makes an HTTP POST request to a given endpoint.
+
+ | |||||||||||
Make an HTTP post to a given URL.
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Initial delay before first retry, without jitter. +
Maximum delay before a retry. +
Default constructor.
key + | API key obtained through the Google API Console. + | +
---|
Sends a message to many devices, retrying in case of unavailability. + +
+ Note: this method uses exponential back-off to retry in + case of service unavailability and hence could block the calling thread + for many seconds.
message + | message to be sent. | +
---|---|
regIds + | registration id of the devices that will receive + the message. | +
retries + | number of retries in case of service unavailability errors. | +
IllegalArgumentException + | if registrationIds is null or + empty. | +
---|---|
InvalidRequestException + | if GCM didn't returned a 200 or 503 status. | +
IOException + | if message could not be sent. + | +
Sends a message to one device, retrying in case of unavailability. + +
+ Note: this method uses exponential back-off to retry in + case of service unavailability and hence could block the calling thread + for many seconds.
message + | message to be sent, including the device's registration id. | +
---|---|
registrationId + | device where the message will be sent. | +
retries + | number of retries in case of service unavailability errors. | +
IllegalArgumentException + | if registrationId is null. | +
---|---|
InvalidRequestException + | if GCM didn't returned a 200 or 5xx status. | +
IOException + | if message could not be sent. + | +
Sends a message without retrying in case of service unavailability. See
+ send(Message, String, int)
for more info.
InvalidRequestException + | if GCM didn't returned a 200 or 5xx status. | +
---|---|
IllegalArgumentException + | if registrationId is null. + | +
IOException + | + |
Sends a message without retrying in case of service unavailability. See
+ send(Message, List, int)
for more info.
IllegalArgumentException + | if registrationIds is null or + empty. | +
---|---|
InvalidRequestException + | if GCM didn't returned a 200 status. | +
IOException + | if there was a JSON parsing error + | +
Adds a new parameter to the HTTP POST body.
body + | HTTP POST body. | +
---|---|
name + | parameter's name. | +
value + | parameter's value. + | +
Gets an HttpURLConnection
given an URL.
+
IOException + | + |
---|
Convenience method to convert an InputStream to a String. +
+ If the stream ends in a newline character, it will be stripped. +
+ If the stream is null, returns an empty string. +
IOException + | + |
---|
Creates a StringBuilder
to be used as the body of an HTTP POST.
name + | initial parameter for the POST. | +
---|---|
value + | initial value for that parameter. | +
Creates a map with just one key-value pair. +
Makes an HTTP POST request to a given endpoint. + +
+ Note: the returned connected should not be disconnected, + otherwise it would kill persistent connections made using Keep-Alive.
url + | endpoint to post the request. | +
---|---|
contentType + | type of request. | +
body + | body of the request. | +
IOException + | propagated from underlying methods. + | +
---|
Make an HTTP post to a given URL.
IOException + | + |
---|
+ About Android | + Legal | + Support +
+Constants | +Constants used on GCM service communication. | +
Message | +GCM message. | +
Message.Builder | ++ |
MulticastResult | +Result of a GCM multicast message request . | +
Result | +Result of a GCM message request that returned HTTP status code 200. | +
Result.Builder | ++ |
Sender | +Helper class to send messages to the GCM service using an API Key. | +
InvalidRequestException | +Exception thrown when GCM returned an error due to an invalid request. | +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.R.attr | +
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
cameraBearing | +Must be a floating point value, such as " |
+ ||||||||||
cameraTargetLat | +Must be a floating point value, such as " |
+ ||||||||||
cameraTargetLng | +Must be a floating point value, such as " |
+ ||||||||||
cameraTilt | +Must be a floating point value, such as " |
+ ||||||||||
cameraZoom | +Must be a floating point value, such as " |
+ ||||||||||
mapType | +Must be one of the following constant values. |
+ ||||||||||
uiCompass | +Must be a boolean value, either " |
+ ||||||||||
uiRotateGestures | +Must be a boolean value, either " |
+ ||||||||||
uiScrollGestures | +Must be a boolean value, either " |
+ ||||||||||
uiTiltGestures | +Must be a boolean value, either " |
+ ||||||||||
uiZoomControls | +Must be a boolean value, either " |
+ ||||||||||
uiZoomGestures | +Must be a boolean value, either " |
+ ||||||||||
useViewLifecycle | +Must be a boolean value, either " |
+ ||||||||||
zOrderOnTop | +Must be a boolean value, either " |
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be one of the following constant values.
+Constant | Value | Description |
---|---|---|
none | 0 | |
normal | 1 | |
satellite | 2 | |
terrain | 3 |
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
+
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.R | +
Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
R.attr | ++ | ||||||||||||||||||||||||||||||||
R.id | ++ | ||||||||||||||||||||||||||||||||
R.string | ++ | ||||||||||||||||||||||||||||||||
R.styleable | ++ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.R.id | +
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
none | ++ | ||||||||||
normal | ++ | ||||||||||
satellite | ++ | ||||||||||
terrain | ++ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.R.string | +
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
common_google_play_services_enable_button | +Button in confirmation dialog to enable Google Play services. | +||||||||||
common_google_play_services_enable_text | +Message in confirmation dialog informing user they need to enable + Google Play services in application settings [CHAR LIMIT=NONE] + | +||||||||||
common_google_play_services_enable_title | +Title of confirmation dialog informing user they need to enable + Google Play services in application settings [CHAR LIMIT=40] + | +||||||||||
common_google_play_services_install_button | +Button in confirmation dialog for installing Google Play services [CHAR LIMIT=30] + | +||||||||||
common_google_play_services_install_text_phone | +(For phones) Message in confirmation dialog informing user that + they need to install Google Play services (from Play Store) [CHAR LIMIT=NONE] + | +||||||||||
common_google_play_services_install_text_tablet | +(For tablets) Message in confirmation dialog informing user that + they need to install Google Play services (from Play Store) [CHAR LIMIT=NONE] + | +||||||||||
common_google_play_services_install_title | +Title of confirmation dialog informing user that they need to install + Google Play services (from Play Store) [CHAR LIMIT=40] + | +||||||||||
common_google_play_services_unknown_issue | +Message in confirmation dialog informing user there is an unknow issue in Google Player + services [CHAR LIMIT=NONE] + | +||||||||||
common_google_play_services_update_button | +Button in confirmation dialog for updating Google Play services [CHAR LIMIT=20] + | +||||||||||
common_google_play_services_update_text | +Message in confirmation dialog informing user that they need to update + Google Play services (from Play Store) [CHAR LIMIT=NONE] + | +||||||||||
common_google_play_services_update_title | +Title of confirmation dialog informing user that they need to update + Google Play services (from Play Store) [CHAR LIMIT=40] + | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Button in confirmation dialog to enable Google Play services. Clicking it + will direct user to application settings of Google Play services where they + can enable it [CHAR LIMIT=30] +
Message in confirmation dialog informing user they need to enable + Google Play services in application settings [CHAR LIMIT=NONE] +
Title of confirmation dialog informing user they need to enable + Google Play services in application settings [CHAR LIMIT=40] +
Button in confirmation dialog for installing Google Play services [CHAR LIMIT=30] +
(For phones) Message in confirmation dialog informing user that + they need to install Google Play services (from Play Store) [CHAR LIMIT=NONE] +
(For tablets) Message in confirmation dialog informing user that + they need to install Google Play services (from Play Store) [CHAR LIMIT=NONE] +
Title of confirmation dialog informing user that they need to install + Google Play services (from Play Store) [CHAR LIMIT=40] +
Message in confirmation dialog informing user there is an unknow issue in Google Player + services [CHAR LIMIT=NONE] +
Button in confirmation dialog for updating Google Play services [CHAR LIMIT=20] +
Message in confirmation dialog informing user that they need to update + Google Play services (from Play Store) [CHAR LIMIT=NONE] +
Title of confirmation dialog informing user that they need to update + Google Play services (from Play Store) [CHAR LIMIT=40] +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.R.styleable | +
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | +MapAttrs_cameraBearing | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_cameraTargetLat | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_cameraTargetLng | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_cameraTilt | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_cameraZoom | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_mapType | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_uiCompass | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_uiRotateGestures | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_uiScrollGestures | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_uiTiltGestures | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_uiZoomControls | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_uiZoomGestures | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_useViewLifecycle | +This symbol is the offset where the |
+ |||||||||
int | +MapAttrs_zOrderOnTop | +This symbol is the offset where the |
+
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MapAttrs | +Attributes that can be used with a MapAttrs. | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
This symbol is the offset where the cameraBearing
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the cameraTargetLat
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the cameraTargetLng
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the cameraTilt
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the cameraZoom
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a floating point value, such as "1.2
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the uiCompass
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the uiRotateGestures
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the uiScrollGestures
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the uiTiltGestures
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the uiZoomControls
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the uiZoomGestures
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the useViewLifecycle
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
This symbol is the offset where the zOrderOnTop
+ attribute's value can be found in the MapAttrs
array.
+
+
+
Must be a boolean value, either "true
" or "false
".
+
This may also be a reference to a resource (in the form
+"@[package:]type:name
") or
+theme attribute (in the form
+"?[package:][type:]name
")
+containing a value of this type.
Attributes that can be used with a MapAttrs. +
Includes the following attributes:
+MapAttrs_cameraBearing
MapAttrs_cameraTargetLat
MapAttrs_cameraTargetLng
MapAttrs_cameraTilt
MapAttrs_cameraZoom
MapAttrs_mapType
MapAttrs_uiCompass
MapAttrs_uiRotateGestures
MapAttrs_uiScrollGestures
MapAttrs_uiTiltGestures
MapAttrs_uiZoomControls
MapAttrs_uiZoomGestures
MapAttrs_useViewLifecycle
MapAttrs_zOrderOnTop
+ About Android | + Legal | + Support +
+java.lang.Object | +|||
↳ | + +java.lang.Throwable | +||
+ + | ↳ | + +java.lang.Exception | +|
+ + | + + | ↳ | + +com.google.android.gms.auth.GoogleAuthException | +
+
+ Known Direct Subclasses
+
+
+
+
+
+
+ UserRecoverableAuthException,
+
+ UserRecoverableNotifiedException
+
+
+
+
+
+
|
+
+ Known Indirect Subclasses
+
+
+
+
+
+
+ GooglePlayServicesAvailabilityException
+
+
+
+
+
+
|
GoogleAuthExceptions signal Google authentication errors. In contrast to
+ IOException
s, GoogleAuthExceptions imply that authentication shouldn't
+ simply be retried.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Throwable
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.auth.GoogleAuthUtil | +
GoogleAuthUtil provides static utility methods to acquire and invalidate + authentication tokens. + +
+ public void onCreate { + // onCreate is called on the main thread, so you must do the work in + // a background thread, which AsyncTask makes easy to do. + getAndUseAuthTokenInAsyncTask(); + } + + ... + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == MY_ACTIVITYS_AUTH_REQUEST_CODE) { + if (resultCode == RESULT_OK) { + getAndUseAuthTokenInAsyncTask(); + } + } + } + + // Example of how to use the GoogleAuthUtil in a blocking, non-main thread context + void getAndUseAuthTokenBlocking() { + try { + // Retrieve a token for the given account and scope. It will always return either + // a non-empty String or throw an exception. + final String token =+ + + + + + + +GoogleAuthUtil
.getToken(Context, String, String)
(context, email, scope); + // Do work with token. + ... + if (server indicates token is invalid) { + // invalidate the token that we found is bad so thatGoogleAuthUtil
won't + // return it next time (it may have cached it) +GoogleAuthUtil
.invalidateToken(Context, String)
(context, token); + // consider retrying getAndUseTokenBlocking() once more + return; + } + return; + } catch (GooglePlayServicesAvailabilityException playEx) { + Dialog alert = GooglePlayServicesUtil.getErrorDialog( + playEx.getConnectionStatusCode(), + this, + MY_ACTIVITYS_AUTH_REQUEST_CODE); + ... + } catch (UserRecoverableAuthException userAuthEx) { + // Start the user recoverable action using the intent returned by + //getIntent()
+ myActivity.startActivityForResult( + userAuthEx.getIntent(), + MY_ACTIVITYS_AUTH_REQUEST_CODE); + return; + } catch (IOException transientEx) { + // network or server error, the call is expected to succeed if you try again later. + // Don't attempt to call again immediately - the request is likely to + // fail, you'll hit quotas or back-off. + ... + return; + } catch (GoogleAuthException authEx) { + // Failure. The call is not expected to ever succeed so it should not be + // retried. + ... + return; + } + } + + // Example of how to use AsyncTask to call blocking code on a background thread. + void getAndUseAuthTokenInAsyncTask() { + AsyncTasktask = new AsyncTask () { + @Override + protected Void doInBackground(Void... params) { + getAndUseAuthTokenBlocking(); + } + }; + task.execute((Void)null); + } +
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | +GOOGLE_ACCOUNT_TYPE | ++ | |||||||||
String | +KEY_HANDLE_NOTIFICATION | ++ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Authenticates the user and returns a valid Google authentication token,
+ or throws an exception if there was an error getting a token.
+
+ | |||||||||||
Authenticates the user and returns a valid Google authentication token, or throws an
+
+
+ Exception if there was an error while getting the token. | |||||||||||
Authenticates the user and returns a valid Google authentication token, or throws an
+
+
+ Exception if there was an error while getting the token. | |||||||||||
Authenticates the user and returns a valid Google authentication token, or throws an
+
+
+ Exception if there was an error while getting the token. | |||||||||||
Authenticates the user and returns a valid Google authentication token, or throws an
+
+
+ Exception if there was an error while getting the token. | |||||||||||
Invalidates the specified token with respect to the
+
+ Context . |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Authenticates the user and returns a valid Google authentication token, + or throws an exception if there was an error getting a token. +
+ The exception thrown depends upon the underlying error and support for
+ recovery. IOException
s will be thrown if the underlying error
+ might be solved by some intelligent retry strategy. Alternatively,
+ GoogleAuthException
s represent a broad class of
+ Exception
s that cannot be recovered from programmatically. Some
+ may be fatal errors stemming from implementation errors while others may
+ require user intervention. UserRecoverableAuthException
s are
+ GoogleAuthExceptions that provide Intent
s which can be used to
+ initiate any user intervention required to fix the underlying error. For
+ example, a UserRecoverableAuthExceptions intent might lead to a request
+ for a user's consent or present the user with a device policy manager
+ download screen. GooglePlayServicesAvailabilityException
s are
+ UserRecoverableAuthExceptions along with a connection status code which
+ allows clients to create a localized Dialog
using
+ getErrorDialog(int, android.app.Activity, int)
.
+ Finally, this method is blocking and shouldn't be called in the main
+ event thread. If so an IllegalStateException
will be thrown.
+
+ Which exceptions should be handled and how depends on the context of the
+ code. For example in the case of an Activity
where
+ the user is actively engaged:
+
+
+ String token; + try { + token = GoogleAuthUtil.getToken(context, accountName, scope); + } catch (GooglePlayServicesAvailabilityException playEx) { + Dialog dialog = GooglePlayServicesUtil.getErrorDialog( + playEx.getConnectionStatusCode(), + Activity.this, + AUTH_REQUEST_CODE); + // Use the dialog to present to the user. + } catch (UserRecoverableAutException recoverableException) { + Intent recoveryIntent = recoverableException.getIntent(); + // Use the intent in a custom dialog or just startActivityForResult. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMesssage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } ++ + On the other hand, explicitly handling a +
GooglePlayServicesAvailabilityException
in the absence of a UI
+ thread may not be worthwhile. Instead a Notification
+ may be preferable.
+
+ + String token; + try { + token = GoogleAuthUtil.getToken(context, accountName, scope); + } catch (UserRecoverableAuthException recoverableException) { + Intent recoveryIntent = recoverableException.getIntent(); + // Use the intent to create a Notification. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMessage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } +
context + | Context associated with the desired token. | +
---|---|
accountName + | String representing the authenticating user account. | +
scope + | String representing the authentication scope. | +
GooglePlayServicesAvailabilityException + | containing the appropriate + connection status error code. | +
---|---|
UserRecoverableAuthException + | wrapping an Intent for initiating
+ user intervention. The wrapped intent must be called with startActivityForResult(Intent, int) . |
+
GoogleAuthException + | signaling a potentially unrecoverable + authentication error. | +
IOException + | signaling a potentially transient error. | +
IllegalArgumentException + | if the method is invoked in the main + event thread. + | +
Authenticates the user and returns a valid Google authentication token, or throws an
+ Exception
if there was an error while getting the token.
+
+ The exception thrown depends upon the underlying error and support for
+ recovery. IOException
s will be thrown if the underlying error
+ might be solved by some intelligent retry strategy. Alternatively,
+ GoogleAuthException
s represent a broad class of
+ Exception
s that cannot be recovered from programmatically. Some
+ may be fatal errors stemming from implementation errors while others may
+ require user intervention. UserRecoverableAuthException
s are
+ GoogleAuthExceptions that provide Intent
s which can be used to
+ initiate any user intervention required to fix the underlying error. For
+ example, a UserRecoverableAuthExceptions intent might lead to a request
+ for a user's consent or present the user with a device policy manager
+ download screen. GooglePlayServicesAvailabilityException
s are
+ UserRecoverableAuthExceptions along with a connection status code which
+ allows clients to create a localized Dialog
using
+ getErrorDialog(int, android.app.Activity, int)
.
+ Finally, this method is blocking and shouldn't be called in the main
+ event thread. If so an IllegalStateException
will be thrown.
+
+ Which exceptions should be handled and how depends on the context of the
+ code. For example in the case of an Activity
where
+ the user is actively engaged:
+
+
+ String token; + try { + token = GoogleAuthUtil.getToken(context, accountName, scope, bundle); + } catch (GooglePlayServicesAvailabilityException playEx) { + Dialog dialog = GooglePlayServicesUtil.getErrorDialog( + playEx.getConnectionStatusCode(), + Activity.this, + AUTH_REQUEST_CODE); + // Use the dialog to present to the user. + } catch (UserRecoverableAutException recoverableException) { + Intent recoveryIntent = recoverableException.getIntent(); + // Use the intent in a custom dialog or just startActivityForResult. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMesssage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } ++ + On the other hand, explicitly handling a +
GooglePlayServicesAvailabilityException
in the absence of a UI
+ thread may not be worthwhile. Instead a Notification
+ may be preferable.
+
+ + String token; + try { + token = GoogleAuthUtil.getToken(context, accountName, scope, bundle); + } catch (UserRecoverableAutException recoverableException) { + Intent recoveryIntent = recoverableException.getIntent(); + // Use the intent to create a Notification. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMesssage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } +
context + | Context associated with the desired token. | +
---|---|
accountName + | String representing the authenticating user account. | +
scope + | String representing the authentication scope. | +
extras + | Bundle containing additional information that may be + relevant to the authentication scope. | +
GooglePlayServicesAvailabilityException + | containing the appropriate + connection status error code. | +
---|---|
UserRecoverableAuthException + | wrapping an Intent for initiating
+ user intervention. The wrapped intent must be called with startActivityForResult(Intent, int) . |
+
GoogleAuthException + | signaling a potentially unrecoverable + authentication error. | +
IOException + | signaling a potentially transient error. | +
IllegalArgumentException + | if the method is invoked in the main + event thread. + | +
Authenticates the user and returns a valid Google authentication token, or throws an
+ Exception
if there was an error while getting the token.
+
+ This method is specifically provided for background tasks. In the event of an error that + needs user intervention, this method takes care of pushing relevant notification. +
+ The exception thrown depends upon the underlying error and support for
+ recovery. UserRecoverableNotifiedException
will be thrown if the error can be
+ resolved by user intervention and a notification has already been posted to address it.
+ IOException
s will be thrown if the underlying error
+ might be solved by some intelligent retry strategy. Alternatively,
+ GoogleAuthException
s represent a broad class of
+ Exception
s that cannot be recovered programmatically.
+
+
+ String token; + try { + token = GoogleAuthUtil.getToken(context, accountName, scope, callback, bundle); + } catch (UserRecoverableNotifiedException userNotifiedException) { + // Notification has already been pushed. + // Continue without token or stop background task. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMesssage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } +
context + | Context associated with the desired token. | +
---|---|
accountName + | String representing the authenticating user account. | +
scope + | String representing the authentication scope. | +
extras + | Bundle containing additional information that may be + relevant to the authentication scope. | +
UserRecoverableNotifiedException + | if a user addressable error occurred and a + notification was pushed. | +
---|---|
GoogleAuthException + | signaling a potentially unrecoverable + authentication error. | +
IOException + | signaling a potentially transient error. | +
IllegalArgumentException + | if the method is invoked in the main + event thread. + | +
Authenticates the user and returns a valid Google authentication token, or throws an
+ Exception
if there was an error while getting the token.
+
+ This method is specifically provided for background tasks. In the event of an error that + needs user intervention, this method takes care of pushing relevant notification. After the + user addresses the notification, the callback is broadcasted. If the user cancels then the + callback is not fired. +
+ The exception thrown depends upon the underlying error and support for
+ recovery. UserRecoverableNotifiedException
will be thrown if the error can be
+ resolved by user intervention and a notification has already been posted to address it.
+ IOException
s will be thrown if the underlying error
+ might be solved by some intelligent retry strategy. Alternatively,
+ GoogleAuthException
s represent a broad class of
+ Exception
s that cannot be recovered programmatically.
+
+
+ String token; + try { + token = GoogleAuthUtil.getToken(context, accountName, scope, callback, bundle); + } catch (UserRecoverableNotifiedException userNotifiedException) { + // Notification has already been pushed. + // Continue without token or stop background task. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMesssage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } +
context + | Context associated with the desired token. | +
---|---|
accountName + | String representing the authenticating user account. | +
scope + | String representing the authentication scope. | +
extras + | Bundle containing additional information that may be + relevant to the authentication scope. | +
callback + | A broadcast intent with a valid receiver that has been exported for other + apps to send broadcasts to it. This intent must be serializable using + toUri(Intent.URI_INTENT_SCHEME) and Intent.parseUri(intentUri, Intent.URI_INTENT_SCHEME). + Cannot be null. | +
UserRecoverableNotifiedException + | if a user addressable error occurred and a + notification was pushed. | +
---|---|
GoogleAuthException + | signaling a potentially unrecoverable + authentication error. | +
IOException + | signaling a potentially transient error. | +
IllegalArgumentException + | if the method is invoked in the main + event thread. + | +
Authenticates the user and returns a valid Google authentication token, or throws an
+ Exception
if there was an error while getting the token.
+
+ This method is specifically provided for sync adaptors. In the event of an error that + needs user intervention, this method takes care of pushing relevant notification. After the + user addresses the notification, a sync request will be kicked off using the given params. + If the user cancels then the sync is not fired. +
+ The exception thrown depends upon the underlying error and support for
+ recovery. UserRecoverableNotifiedException
will be thrown if the error can be
+ resolved by user intervention and a notification has already been posted to address it.
+ IOException
s will be thrown if the underlying error
+ might be solved by some intelligent retry strategy. Alternatively,
+ GoogleAuthException
s represent a broad class of
+ Exception
s that cannot be recovered programmatically.
+
+
+ String token; + try { + token = GoogleAuthUtil.getToken( + context, accountName, scope, authority, syncBundle, bundle); + } catch (UserRecoverableNotifiedException userNotifiedException) { + // Notification has already been pushed. + // Continue without token or stop background task. + } catch (GoogleAuthException authEx) { + // This is likely unrecoverable. + Log.e(TAG, "Unrecoverable authentication exception: " + authEx.getMesssage(), authEx); + } catch (IOException ioEx) { + Log.i(TAG, "transient error encountered: " + ioEx.getMessage()); + doExponentialBackoff(); + } +
context + | Context associated with the desired token. | +
---|---|
accountName + | String representing the authenticating user account. | +
scope + | String representing the authentication scope. | +
extras + | Bundle containing additional information that may be + relevant to the authentication scope. | +
authority + | Authority for firing a sync request. Must not be empty or null. | +
syncBundle + | extras for firing a sync request. This bundle must pass + ContentResolver.validateSyncExtrasBundle(). If no extras are needed can a null value + can be passed. | +
UserRecoverableNotifiedException + | if a user addressable error occurred and a + notification was pushed. | +
---|---|
GoogleAuthException + | signaling a potentially unrecoverable + authentication error. | +
IOException + | signaling a potentially transient error. | +
IllegalArgumentException + | if the method is invoked in the main + event thread. + | +
Invalidates the specified token with respect to the Context
.
+ Note that the context must be the same as that used to initialize
+ the token in a previous call to
+ getToken(Context, String, String)
or
+ getToken(Context, String, String, Bundle)
.
context + | Context of the token. | +
---|---|
token + | String containing the token to invalidate. + | +
+ About Android | + Legal | + Support +
+java.lang.Object | +|||||
↳ | + +java.lang.Throwable | +||||
+ + | ↳ | + +java.lang.Exception | +|||
+ + | + + | ↳ | + +com.google.android.gms.auth.GoogleAuthException | +||
+ + | + + | + + | ↳ | + +com.google.android.gms.auth.UserRecoverableAuthException | +|
+ + | + + | + + | + + | ↳ | + +com.google.android.gms.auth.GooglePlayServicesAvailabilityException | +
GooglePlayServicesAvailabilityExceptions are special instances of
+ UserRecoverableAuthException
s which are thrown when the expected Google Play services app
+ is not available for some reason. In these cases client code can use
+ getConnectionStatusCode()
in conjunction with
+ getErrorDialog(int, android.app.Activity, int)
+ to provide users with a localized Dialog
that will allow users to install,
+ update, or otherwise enable Google Play services.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ com.google.android.gms.auth.UserRecoverableAuthException
+
+
+
+
+
+
+
+
| |||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Throwable
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
+ About Android | + Legal | + Support +
+java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +com.google.android.gms.auth.GoogleAuthException | +|
+ + | + + | + + | ↳ | + +com.google.android.gms.auth.UserRecoverableAuthException | +
+
+ Known Direct Subclasses
+
+
+
+
+
+
+ GooglePlayServicesAvailabilityException
+
+
+
+
+
+
|
UserRecoverableAuthExceptions signal Google authentication errors that can be recovered with user + action, such as a user login. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Getter for an
+
+ Intent that when supplied to startActivityForResult(Intent, int) , will allow user intervention. |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Throwable
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Getter for an Intent
that when supplied to startActivityForResult(Intent, int)
, will allow user intervention.
+ About Android | + Legal | + Support +
+java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +com.google.android.gms.auth.GoogleAuthException | +|
+ + | + + | + + | ↳ | + +com.google.android.gms.auth.UserRecoverableNotifiedException | +
UserRecoverableNotifiedException signals that there was a Google authentication error which can + be recovered with user action and has been handled by publishing a notification for the user + to act on. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Throwable
+
+
+
+
+
+
+
+ | |||||||||||||||||||||||||||||||||
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
+ About Android | + Legal | + Support +
+GoogleAuthUtil | +GoogleAuthUtil provides static utility methods to acquire and invalidate + authentication tokens. | +
GoogleAuthException | +GoogleAuthExceptions signal Google authentication errors. | +
GooglePlayServicesAvailabilityException | +GooglePlayServicesAvailabilityExceptions are special instances of
+ UserRecoverableAuthException s which are thrown when the expected Google Play services app
+ is not available for some reason. |
+
UserRecoverableAuthException | +UserRecoverableAuthExceptions signal Google authentication errors that can be recovered with user + action, such as a user login. | +
UserRecoverableNotifiedException | +UserRecoverableNotifiedException signals that there was a Google authentication error which can + be recovered with user action and has been handled by publishing a notification for the user + to act on. | +
+ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.common.AccountPicker | +
Common account picker similar to the standard framework account picker introduced in ICS:
+ newChooseAccountIntent
.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns an intent to an
+
+ Activity that prompts the user to choose from a list of
+ accounts. |
+ [Expand]
+ Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+
+
+ |
Returns an intent to an Activity
that prompts the user to choose from a list of
+ accounts.
+ The caller will then typically start the activity by calling
+ startActivityForResult(intent, ...);
.
+
+ On success the activity returns a Bundle with the account name and type specified using
+ keys KEY_ACCOUNT_NAME
and KEY_ACCOUNT_TYPE
.
+
+ The most common case is to call this with one account type, e.g.: +
+
+ Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"}, + false, null, null, null, null); + startActivityForResult(intent, SOME_REQUEST_CODE); ++ + The account picker activity will return when use has selected and/or created an account, + and the resulting account name can be retrieved as follows: +
+ protected void onActivityResult(final int requestCode, final int resultCode, + final Intent data) { + if (requestCode == SOME_REQUEST_CODE && resultCode == RESULT_OK) { + String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); + } + } +
selectedAccount + | if specified, indicates that the Account is the currently
+ selected one, according to the caller's definition of selected. |
+
---|---|
allowableAccounts + | an optional ArrayList of accounts that are allowed to be
+ shown. If not specified then this field will not limit the displayed accounts. |
+
allowableAccountTypes + | an optional string array of account types. These are used + both to filter the shown accounts and to filter the list of account types that are shown + when adding an account. | +
alwaysPromptForAccount + | if set the account chooser screen is always shown, otherwise + it is only shown when there is more than one account from which to choose | +
descriptionOverrideText + | if non-null this string is used as the description in the + accounts chooser screen rather than the default | +
addAccountAuthTokenType + | this string is passed as the addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback
+ authTokenType parameter |
+
addAccountRequiredFeatures + | this string array is passed as the
+ addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback requiredFeatures parameter |
+
addAccountOptions + | This Bundle is passed as the
+ addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback options parameter |
+
Intent
that can be used to launch the ChooseAccount activity flow.
++ About Android | + Legal | + Support +
+java.lang.Object | +|
↳ | + +com.google.android.gms.common.ConnectionResult | +
Contains all possible error codes for when a client fails to connect to Google Play services.
+ These error codes are used by GooglePlayServicesClient.OnConnectionFailedListener
.
+
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | +DEVELOPER_ERROR | +The application is misconfigured. | +|||||||||
int | +INTERNAL_ERROR | +An internal error occurred. | +|||||||||
int | +INVALID_ACCOUNT | +The client attempted to connect to the service with an invalid account name + specified. | +|||||||||
int | +NETWORK_ERROR | +A network error occurred. | +|||||||||
int | +RESOLUTION_REQUIRED | +Completing the connection requires some form of resolution. | +|||||||||
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_VERSION_UPDATE_REQUIRED | +The installed version of Google Play services is out of date. | +|||||||||
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. | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a connection result.
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Indicates the type of error that interrupted connection.
+
+ | |||||||||||
A pending intent to resolve the connection failure.
+
+ | |||||||||||
Returns true if calling
+
+ startResolutionForResult(Activity, int)
+ will start any intents requiring user interaction. | |||||||||||
Returns true if the connection was successful.
+
+ | |||||||||||
Resolves an error by starting any intents requiring user
+ interaction.
+
+ |
+ [Expand]
+ Inherited Methods | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
+
+From class
+
+ java.lang.Object
+
+
+
+
+
+ |