-1

I have two activities A & B. in A, i am showing a list of titles, and on clicking a title, it will open the detailed article in activity B.

I declare A as singleinstance in Manifest.

But if I declare A as single instance, and when the Activity B is opened and paused, then Activity A is not available on backstack.

I will try to explain by reproducing:

  1. Activity A (launchMode = SingleInstance) with list of titles.
  2. On clicking a title, Activity B opens
  3. On clicking back button/up navigation, Acitiviy B finishes and Activity A resumes.
  4. Again open activity B.
  5. Press home button of device (Activity B goes to background - onPause)
  6. Activity B is available in Recent Apps
  7. Open app from recent apps/launcer - Activity B opens
  8. Clicking back button/up navigation - Act B finishes, but Act A not resumed.

How can I provide better up navigation?

Arun Shankar
  • 2,603
  • 2
  • 26
  • 36
  • Is singleInstance a requirement? If not, I think you overcomplicated a simple task. Don't change launchMode at all and you'll get needed behaviour. – Spidey Aug 25 '16 at 03:53
  • @Spidey Then its not showing in recent apps if the Act B is opened – Arun Shankar Aug 25 '16 at 05:41
  • That behaviour is not normal. Update your question with manifest for activites and checkout this link http://stackoverflow.com/questions/3762763/how-to-remove-application-from-recent-application-list. By default any activity should always appear in recent apps list. – Spidey Aug 25 '16 at 13:05

2 Answers2

1

For my idea, you can change lauchmode of Activity A and Activity B from Singleinstance to android:launchMode="singleTop". I work fine for me. It is well said here. Let try.

K.Sopheak
  • 22,904
  • 4
  • 33
  • 78
0

When you will press the home button the activity B would call onStop() method. For a better understanding you can refer to https://developer.android.com/guide/components/tasks-and-back-stack.html