public
class
GcmIntentService
extends
IntentService {
....
public
GcmIntentService() {
super
(
"GcmIntentService"
);
}
@Override
protected
void
onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(
this
);
String messageType = gcm.getMessageType(intent);
if
(!extras.isEmpty()) {
if
(GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
Context context = getApplicationContext();
Intent in =
new
Intent(context, MainActivity.
class
);
in.putExtras(intent.getExtras());
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(in);
...
Log.i(TAG,
"Received: "
+ extras.toString());
}
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
...
}