Android Click On Notification Does Not Open The Attached Activity
I want to open an Activity when I click on the notification from the Status bar. I have seen this answered on StackOverflow but none of these answers work for me. This issue is on
Solution 1:
try adding Intent.FLAG_ACTIVITY_CLEAR_TASK flag in the intent
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
this seems to solve my problem
Solution 2:
Have you set the pending intent in the notification setContentIntent method?
Try this, it works for me on all api versions
Intentintent=newIntent(this, TestActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntentpendingIntent= PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.BuildernotificationBuilder=newNotificationCompat.Builder(this)
.setSmallIcon(R.drawable.logo)
.setContentTitle(getResources().getString(R.string.notification_title))
.setContentIntent(pendingIntent);
NotificationManagernotificationManager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
Post a Comment for "Android Click On Notification Does Not Open The Attached Activity"