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??
Try this code instead:
String notification = getIntent().getStringExtra("notification");
String notifiedby = getIntent().getStringExtra("notifiedby");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With