I have a transparent activity which is used for getting an AlertDialog. This AlertDialog appears anytime my app gets a push notification(foreground or background). But when the AlertDialog appears and if there is an another Activity in the background AlertDialog appears on top of this Activity. I want to see only the AlertDialog when user taps the notification.
Here is the code that shows the AlertDialog when app is foreground
Intent dialogIntent = new Intent(getApplicationContext(), DialogActivity.class);
MainActivity.this.startActivity(dialogIntent);
MainActivity.this.finish();
And when app is background i use PendingIntent
Intent dialogIntent = new Intent(getApplicationContext(), DialogActivity.class);
final PendingIntent resultPendingIntent =
PendingIntent.getActivity(
mContext,
0,
dialogIntent ,
PendingIntent.FLAG_CANCEL_CURRENT
);
Is there a solution for showing only AlertDialog when user taps the notification ? Any help would be appreciated.