public abstract class

GCMBaseIntentService

extends IntentService
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.app.IntentService
           ↳ com.google.android.gcm.GCMBaseIntentService

This class is deprecated.
Please use the GoogleCloudMessaging API instead.

Class Overview

Skeleton for application-specific IntentServices 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.

Summary

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
GCMBaseIntentService()
Constructor that does not set a sender id, useful when the sender id is context-specific.
GCMBaseIntentService(String... senderIds)
Constructor used when the sender id(s) is fixed.
Public Methods
final void onHandleIntent(Intent intent)
Protected Methods
String[] getSenderIds(Context context)
Gets the sender ids.
void onDeletedMessages(Context context, int total)
Called when the GCM server tells pending messages have been deleted because the device was idle.
abstract void onError(Context context, String errorId)
Called on registration or unregistration error.
abstract void onMessage(Context context, Intent intent)
Called when a cloud message has been received.
boolean onRecoverableError(Context context, String errorId)
Called on a registration error that could be retried.
abstract void onRegistered(Context context, String registrationId)
Called after a device has been registered.
abstract void onUnregistered(Context context, String registrationId)
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

Constants

public static final String TAG

Old TAG used for logging. Marked as deprecated since it should have been private at first place.

Constant Value: "GCMBaseIntentService"

Protected Constructors

protected GCMBaseIntentService ()

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.

protected GCMBaseIntentService (String... senderIds)

Constructor used when the sender id(s) is fixed.

Public Methods

public final void onHandleIntent (Intent intent)

Protected Methods

protected String[] getSenderIds (Context context)

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.

Throws
IllegalStateException if sender id was not set on constructor.

protected void onDeletedMessages (Context context, int total)

Called when the GCM server tells pending messages have been deleted because the device was idle.

Parameters
context application's context.
total total number of collapsed messages

protected abstract void onError (Context context, String errorId)

Called on registration or unregistration error.

Parameters
context application's context.
errorId error id returned by the GCM service.

protected abstract void onMessage (Context context, Intent intent)

Called when a cloud message has been received.

Parameters
context application's context.
intent intent containing the message payload as extras.

protected boolean onRecoverableError (Context context, String errorId)

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.

Parameters
context application's context.
errorId error id returned by the GCM service.
Returns
  • if true, failed operation will be retried (using exponential backoff).

protected abstract void onRegistered (Context context, String registrationId)

Called after a device has been registered.

Parameters
context application's context.
registrationId the registration id returned by the GCM service.

protected abstract void onUnregistered (Context context, String registrationId)

Called after a device has been unregistered.

Parameters
context application's context.
registrationId the registration id that was previously registered.