My pending intent not working as to be expected to work.
Issue is: When tapping on Notification it redirects to Splash Activity that is my launcher Activity of application, following is my code for creating notification.
Intent intent = new Intent(this, QuickTasks.class).putExtra("NOTIFICATION", 1);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent resultIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri notificationSoundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Suvi")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(notificationSoundURI)
.setContentIntent(resultIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, mNotificationBuilder.build());
Please help me in this regard i have used many of resources available here, but none of worked. Any help could be appreciable.
Generally, when you want to start an activity from a notification , there is two cases:
Please refer to the following link.
Preserving Navigation when Starting an Activity
I hope this helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.