Android : Intent delivering null content to app when the app is open in onNewIntent and onResume

on Friday, August 8, 2014


Hi all I am having a app which uses ccs to get delivery of the cloud messaging.


I built up the notification using the below code



Intent intent = new Intent(this, GcmActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("title",messagetype);
intent.putExtra("message", msg);
intent.putExtra("additional", additionalInfo);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_cloud)
.setContentTitle(messagetype)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg)
.setTicker(msg)
.setAutoCancel(true)
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);

mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(randInt(1, 1000), mBuilder.build());


Now when I click on the notification when app is not opened, it delivers the intent and I show them on a list.


However they are all null when clicked when the app is opened. Actually why I want this to be delivered when app is opened cause I have a broadcastreceiver which update listview which does not updated when the screen is asleep. I send the broadcast just before this code.


I know this something to do with the FLags so, I tried adding in my intent



Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP


With no results. Please let me know if you have any help.


Thanx


0 comments:

Post a Comment