I am using the following code to launch a notification when a Service is started Via AlarmManager:
nm = (NotificationManager) this.getSystemService(Context.N
I did it,
I add Intent.FLAG_ACTIVITY_CLEAR_TOP to new intent
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,
"A new notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(this, NoficationDemoActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Bundle bundle = new Bundle();
bundle.putString("buzz", "buzz");
intent.putExtras(bundle);
PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "This is the title",
"This is the text", activity);
notification.number += 1;
notificationManager.notify(0, notification);
Oncreate i do as follow:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if(getIntent().getExtras()!=null){
Toast.makeText(this, "Click", Toast.LENGTH_SHORT).show();
}