-1

Suppose I have a backstack of activities let's say A-B-C. Now I am at Activity C at the moment. Now a push notification is hit and when i touch the notification it creates another back stack of the same app as D-F. So when I press back button at activity D, how can I go back to the C activity in previous backstack.

So I just normally would like to go back to the previous task in my app when i touch a notification and redirect to another activity. Thanks in advance..

Akshat Vajpayee
  • 274
  • 1
  • 3
  • 15

1 Answers1

1
    Intent i1= new Intent(context, C.class);
    i1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    Intent intent = new Intent(context, D.class);

    final PendingIntent pendingIntent = PendingIntent.getActivities(context, UNIQUE_REQUEST_CODE++,
            new Intent[] {i1, intent}, PendingIntent.FLAG_ONE_SHOT);
Android Geek
  • 8,956
  • 2
  • 21
  • 35
  • But I need to hard code each activity in my previous back stack to get the behaviour. I need a solution from where I can move back to the previous task like profile page or email page or what ever. So I need a dynamic solution or I just use single back stack to achieve all this? – Akshat Vajpayee May 07 '16 at 06:28
  • @AkshatVajpayee Well i didn't get u what u want. but here is link: http://stackoverflow.com/questions/7614429/notification-opens-activity-back-button-pressed-main-activity-is-opened – Android Geek May 07 '16 at 06:53