Cocos2d-x and Android GCM Notifications.

Cocos2d-x and Android GCM Notifications.
0.0 0



I’m making a game where I have to integrate notifications android GCM.

The notification system is created, and if I get a notification when the application is closed everything is working properly.
But if I get a notification when the application is open, pendingIntent class opens a new intent (NotificationActivity) that closing a black screen appears.

I searched google any example that integrated notification system GCM, but found nothing.

Someone could help me. I would be very grateful.
Thank you.


Have the same problem. But i am integrate Alarm Notificaton.
Problem with create Activity with Game:

Intent notificationIntent = new Intent(context, MyGameActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context,

notification.setLatestEventInfo(context, note, title, contentIntent);

manger.notify(NOTIFICATION_ID++, notification);


Solved by this code

NotificationManager manger = (NotificationManager) context
Notification notification = new Notification(R.drawable.icon,
“Game!”, System.currentTimeMillis());
Intent notificationIntent = new Intent(context, MyGame.class);
Bundle extras = intent.getExtras();
String title = extras.getString(“title”);
String note = extras.getString(“note”);
int notifId = extras.getInt(“notifId”);
PendingIntent contentIntent = PendingIntent.getActivity(context,
notifId, notificationIntent,PendingIntent.FLAG_ONE_SHOT); // by add this important flag problem was solved
notification.setLatestEventInfo(context,note, title, contentIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
manger.notify(notifId, notification);