|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectIntentService
com.google.android.gcm.GCMBaseIntentService
public abstract class 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.
Field Summary | |
---|---|
static java.lang.String |
TAG
|
Constructor Summary | |
---|---|
protected |
GCMBaseIntentService()
Constructor that does not set a sender id, useful when the sender id is context-specific. |
protected |
GCMBaseIntentService(java.lang.String... senderIds)
Constructor used when the sender id(s) is fixed. |
Method Summary | |
---|---|
protected java.lang.String[] |
getSenderIds(Context context)
Gets the sender ids. |
protected void |
onDeletedMessages(Context context,
int total)
Called when the GCM server tells pending messages have been deleted because the device was idle. |
protected abstract void |
onError(Context context,
java.lang.String errorId)
Called on registration or unregistration error. |
void |
onHandleIntent(Intent intent)
|
protected abstract void |
onMessage(Context context,
Intent intent)
Called when a cloud message has been received. |
protected boolean |
onRecoverableError(Context context,
java.lang.String errorId)
Called on a registration error that could be retried. |
protected abstract void |
onRegistered(Context context,
java.lang.String registrationId)
Called after a device has been registered. |
protected abstract void |
onUnregistered(Context context,
java.lang.String registrationId)
Called after a device has been unregistered. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TAG
Constructor Detail |
---|
protected GCMBaseIntentService()
When using this constructor, the subclass must
override getSenderIds(Context)
, otherwise methods such as
onHandleIntent(Intent)
will throw an
IllegalStateException
on runtime.
protected GCMBaseIntentService(java.lang.String... senderIds)
Method Detail |
---|
protected java.lang.String[] getSenderIds(Context context)
By default, it returns the sender ids passed in the constructor, but it could be overridden to provide a dynamic sender id.
java.lang.IllegalStateException
- if sender id was not set on constructor.protected abstract void onMessage(Context context, Intent intent)
context
- application's context.intent
- intent containing the message payload as extras.protected void onDeletedMessages(Context context, int total)
context
- application's context.total
- total number of collapsed messagesprotected boolean onRecoverableError(Context context, java.lang.String errorId)
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.
protected abstract void onError(Context context, java.lang.String errorId)
context
- application's context.errorId
- error id returned by the GCM service.protected abstract void onRegistered(Context context, java.lang.String registrationId)
context
- application's context.registrationId
- the registration id returned by the GCM service.protected abstract void onUnregistered(Context context, java.lang.String registrationId)
registrationId
- the registration id that was previously registered.context
- application's context.public final void onHandleIntent(Intent intent)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |