Android APIs
public abstract class

GcmListenerService

extends Service
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ com.google.android.gms.gcm.GcmListenerService

Class Overview

Base class for communicating with Google Cloud Messaging.

It also provides functionality such as automatically displaying notifications when requested by app server.

Override base class methods to handle any events required by the application. Methods are invoked asynchronously.

Include the following in the manifest:

 <service
     android:name=".YourGcmListenerService"
     android:exported="false" >
     <intent-filter>
         <action android:name="com.google.android.c2dm.intent.RECEIVE" />
     </intent-filter>
 </service>

Summary

[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
GcmListenerService()
Public Methods
final IBinder onBind(Intent intent)
void onDeletedMessages()
Called when GCM server deletes pending messages due to exceeded storage limits, for example, when the device cannot be reached for an extended period of time.
void onMessageReceived(String from, Bundle data)
Called when a message is received.
void onMessageSent(String msgId)
Called when an upstream message has been successfully sent to the GCM connection server.
void onSendError(String msgId, String error)
Called when there was an error sending an upstream message.
final int onStartCommand(Intent intent, int flags, int startId)
[Expand]
Inherited Methods
From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Public Constructors

public GcmListenerService ()

Public Methods

public final IBinder onBind (Intent intent)

public void onDeletedMessages ()

Called when GCM server deletes pending messages due to exceeded storage limits, for example, when the device cannot be reached for an extended period of time.

It is recommended to retrieve any missing messages directly from the app server.

public void onMessageReceived (String from, Bundle data)

Called when a message is received.

Parameters
from describes message sender.
data message data as String key/value pairs.

public void onMessageSent (String msgId)

Called when an upstream message has been successfully sent to the GCM connection server.

Parameters
msgId of the upstream message sent using send(String, String, Bundle).

public void onSendError (String msgId, String error)

Called when there was an error sending an upstream message.

Parameters
msgId of the upstream message sent using send(String, String, Bundle).
error description of the error.

public final int onStartCommand (Intent intent, int flags, int startId)