I am using this code to show the local notification and When notification comes then on click of notification want to launch the ListActivity but on Google nexus device ListActiviy
is not launches when click on notification, but on other device this code is working well.
Intent notificationIntent = new Intent(context, ListActivity.class); notificationIntent.putExtra("clicked", "Notification Clicked"); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // To open only one activity on launch. PendingIntent pIntent = PendingIntent.getActivity(context, reqCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationManager nM = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notify = new NotificationCompat.Builder( context); notify.setContentIntent(pIntent); notify.setSmallIcon(R.drawable.app_icon); notify.setContentTitle("Hello World"); notify.setContentText(""); notify.setAutoCancel(true); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); notify.setSound(alarmSound); notify.setLights(Color.BLUE, 500, 1000); nM.notify(reqCode, notify.build());
Adding logcat when the activity is not launched:
03-26 14:22:35.893: W/ActivityManager(515): Permission Denial: starting Intent { cmp=com.x.y/.music.ui.PlaybackActivity bnds=[42,101][636,186] (has extras) } from null (pid=-1, uid=10121) not exported from uid 10126 03-26 14:22:35.893: W/ActivityManager(515): Unable to send startActivity intent 03-26 14:22:35.893: W/ActivityManager(515): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.x.y/.music.ui.PlaybackActivity bnds=[42,101][636,186] (has extras) } from null (pid=-1, uid=10121) not exported from uid 10126 03-26 14:22:35.893: W/ActivityManager(515): at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1186) 03-26 14:22:35.893: W/ActivityManager(515): at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:741) 03-26 14:22:35.893: W/ActivityManager(515): at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:3300) 03-26 14:22:35.893: W/ActivityManager(515): at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:252) 03-26 14:22:35.893: W/ActivityManager(515): at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:192) 03-26 14:22:35.893: W/ActivityManager(515): at android.content.IIntentSender$Stub.onTransact(IIntentSender.java:64) 03-26 14:22:35.893: W/ActivityManager(515): at android.os.Binder.execTransact(Binder.java:404) 03-26 14:22:35.893: W/ActivityManager(515): at dalvik.system.NativeStart.run(Native Method)
Go to Settings > Notifications & status bar > Notification Manager > select the app and turn on "Allow Notifications", "Display on Lockscreen", "Display at the top of the screen", "Notification Sound and Vibration", and "Priority notification". Then, restart your phone.
Cause of Notifications Not Showing up on AndroidDo Not Disturb or Airplane Mode is on. Either system or app notifications are disabled. Power or data settings are preventing apps from retrieving notification alerts. Outdated apps or OS software can cause apps to freeze or crash and not deliver notifications.
This is reported issue for kitkat 4.4 not opening activity when click on notification here is an issue url
http://code.google.com/p/android/issues/detail?id=63236
http://code.google.com/p/android/issues/detail?id=61850
suggested workaround is to cancel existing PendingIntent
, or use PendingIntent.FLAG_CANCEL_CURRENT
OR
Try below
Adding a flag in Activity
in AndroidManifiest.xml
android:exported="true"
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