Below i am having code for two notifications and in intent i am passing extras with key1
and key2
but in NotificationPillDescription.class
i am only able to get key1 using getExtras.
// Notification Code For First Notification
Notification notification = new Notification(R.drawable.ic_launcher, "Take your morning pill!", System.currentTimeMillis());
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notifyIntent = new Intent(getApplicationContext(), NotificationPillDescription.class);
Bundle extras = new Bundle();
extras.putString("Key1", String.valueOf(1));
notifyIntent.putExtras(extras);
contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notifyIntent, 0);
notification.setLatestEventInfo(this, "Take your Morning pill!", "My Drug", contentIntent);
notificationManager.notify(dataProvider.notificationId++, notification);
// Notification Code For Second Notification
notifyIntent = new Intent(getApplicationContext(), NotificationPillDescription.class);
Bundle extras = new Bundle();
extras.putString("Key2", String.valueOf(2));
notifyIntent.putExtras(extras);
contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notifyIntent, 0);
notification.setLatestEventInfo(this, "Take your Morning pill!", "My Drug", contentIntent);
notificationManager.notify(dataProvider.notificationId++, notification);
//Code for NotificationPillDescription.class
Bundle extras = getIntent().getExtras();
if(extras != null){
if(extras.containsKey(String.valueOf(1)))
{
Log.d("Pill Id0",extras.getString(String.valueOf(1)) );
}
else
{
Log.d("Pill Id1",extras.getString(String.valueOf(2)) );
}
}