user4759076
user4759076

Reputation: 39

Going back to previous screen

Let say i have activity a,b,c,d . I can open d from any of the Activity . Now I want when user press back button from D it should go back to prev screen but D should be in stack so i can not call finish() . I tried with

intent with clear top flag or

  Intent i = new Intent();
   i.setAction(Intent.ACTION_MAIN);
   i.addCategory(Intent.CATEGORY_LAUNCHER);
   startActivity(i);

when i press back on D it showing notification when he click on notification (even app is in background or foreground)it should kill D Activity

Upvotes: 3

Views: 307

Answers (1)

Karakuri
Karakuri

Reputation: 38595

Use the FLAG_ACTIVITY_REORDER_TO_FRONT flag in the intent.

Intent intent = new Intent(context /*e.g. ActivityD*/, ActivityB.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);

Upvotes: 1

Related Questions