0

I have a problem with navigating to current back stack when handling notification. I have two activities, activity A called activity B, the current back stack is A, B. After that, I tap to Home button -> Navigate to Home screen. At that time, my application receives a notification. When handling that notification, I want to open my application with back stack is A, B and B keeps current its state.

Which way can I solve this problem?

Thanks for help.

Quang Tuan
  • 43
  • 4
  • http://developer.android.com/guide/topics/ui/notifiers/notifications.html . check **Preserving Navigation when Starting an Activity.** – Raghunandan Dec 13 '13 at 07:06
  • If activity A calls activity C, and activity C calls activity D, and also activity A can call activity B, how to solve this case? (Whether current activity is B or D, I want to keep current back stack.) – Quang Tuan Dec 13 '13 at 07:40

1 Answers1

0

Try this:

  1. In Manifest set android:launchMode="singleTask" for ActivityB.
  2. In your Notification set PendingIntent that will call ActivityB.
nfirex
  • 1,523
  • 18
  • 24
  • If activity A calls activity C, and activity C calls activity D, and also activity A can call activity B, how to solve this case? (Whether current activity is B or D, I want to keep current back stack.) – Quang Tuan Dec 13 '13 at 07:39
  • @user2298077 , Sorry? If ActivityB is on top of backstack then you will show ActivityB and the backstack will not changed. But if ActivityB is not on top of backstack then backstack will change - all activities that have been created after ActivityB will be destroyed. If you don't have ActivityB in backstack then only ActivityB will open. – nfirex Dec 13 '13 at 10:43
  • Maybe you need to use this for your second situation: http://stackoverflow.com/a/13632559/1001401 – nfirex Dec 13 '13 at 10:50