I have a notification service running that will create a notification for the user and if the user clicks the notification it opens an activity to display the message, the method I am using to create the notification is :
public void createNotificationMsg(String name,String doing, boolean persistent){
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),
0, new Intent(getApplicationContext(), MessageNotificationActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP).putExtra("message", doing),
PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder notificationBuilder =
(NotificationCompat.Builder) new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.my_logo_96)
.setContentTitle(name)
.setContentText(doing)
.setPriority(Notification.PRIORITY_HIGH)
.setDefaults(Notification.DEFAULT_ALL)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_HIGH)
.setColor(Color.parseColor("#1aadce"));
if (persistent){
notificationBuilder.setOngoing(true);
}
else {
notificationBuilder.setOngoing(false);
}
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(getApplicationContext());
Notification notification = notificationBuilder.build();
notificationManager.notify(0, notification);
}
the MessageNotificationActivity is using the "android:style/Theme.Dialog" to make it look like a dialog now the thing is that when I click on the notification everything goes well and the activity is opened like a dialog with nothing in the background but if the app is paused and is in background when I click the notification it brings the apps Main activity to the front and then opens the MessageNotiicationActivity on top of it. How can I make the notification not bring the main activity to front and only intent to the specefied activity?