I am attempting to raise a notification that a message has arrived. I have added an action expecting an icon (smallredball) to show on the notification. I expect that if the user hits smallredball, main activity will startup and the activity, checking the extras bundle, will see the orders to do something different than if it were just started up normally.
The notification shows on the target phone (running KitKat) along with the text but the smallredball icon never shows. When the user touches the notification the activity executes with no extra. EDIT: THE ACTIVITY IS NOW GETTING THE EXTRA BUNDLE.
This is the code sending the notification:
private void raiseNotification( String username, String mesText)
{
DebugLog.debugLog("GCMIntentService: Attempting to Raise Notification ", false);
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("whattodo", "showmessage");
intent.setAction(Long.toString(System.currentTimeMillis())); //just to make it unique from the next one
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
b.setContentTitle("New SafeTalk Message")
.setSmallIcon(R.drawable.note24x24)
.setContentText("From " + username + " " + mesText)
.setTicker("New SafeTalk Message")
.setContentIntent(pIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setAutoCancel(true)
.addAction(R.drawable.smallredball, "Read Now", pIntent);
NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
mgr.notify(0, b.build());
}
this is a code snippet from the activity:
Bundle extras = getIntent().getExtras();
if (extras == null)
{
GlobalStuff.mpBad.start();
}
else
{
String myOrders = extras.getString("whattodo");
if (myOrders.equals("showmessage"))
GlobalStuff.mpBeep.start();
}
Why isn't the icon showing in the notification? Since I setAutoCancel to true, I expected that simply touching the notification would make it just go away. But instead it runs the app providing no extra bundle? Thanks, Dean