Reputation: 24012
This is my showNotification method in the Service class:
private void showNotification() {
Notification notification = new Notification(R.drawable.icon,
"New Notification", System.currentTimeMillis());
Intent i = new Intent(this, myActivity.class);
i.putExtra("notification", "MyNotif");
i.putExtra("notifiedby", "NotedBy");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0);
notification.setLatestEventInfo(this, "NotedBy", "MyNotif", contentIntent);
nm.notify(111, notification);
}
so after clicking on the Notification from the status bar, i will end up in myActivity.
The problem is these lines always gives false in the myActivity.
this.getIntent().hasExtra("notification")
this.getIntent().hasExtra("notifiedby")
Doesn't putExtra() work with PendingIntent??
Upvotes: 5
Views: 3157
Reputation: 20563
Try this code instead:
String notification = getIntent().getStringExtra("notification");
String notifiedby = getIntent().getStringExtra("notifiedby");
Upvotes: 6