0

At times I will launch one of my app's activities, either using something like an IntentFilter or a Service etc. Once the user has done what he needs to in my app's Activity for the time being, I want the app to resume whichever app/activity the user was in prior to the service bringing my app to the foreground.

The only way I can think of doing this is as per this previous question, determine the foreground app's package name before bringing my app/Activity to the foreground. Then, when I want resume that app to the foreground, I launch the application given its package name, as per this question.

But there are some problems: firstly it needs the GET_TASKS permission. Secondly, I would need to determine the foreground application before my Activity launches. It would be handy to determine the previous app/activity after mine is launched (Or better yet, just restore to it without having to know anything about it)

Are there alternatives to my method above?

Community
  • 1
  • 1
Jodes
  • 14,118
  • 26
  • 97
  • 156

1 Answers1

1

You can just finish your application and as I know android OS will resume previous opened application.

Also look at this question How to bring an activity to foreground (top of stack)? maybe it will help you.

Community
  • 1
  • 1
StupidFox
  • 376
  • 3
  • 19
  • finish() forces my app to be destroyed, I would like to leave it up to Android whether it should just be paused, stopped or destroyed, as it isn't just being called for a result. As for the link to that question, you need to know what Activity was previously up? – Jodes Aug 18 '14 at 20:15
  • This link helped: http://stackoverflow.com/questions/5911101/how-to-send-my-activity-to-background-and-resume – Jodes Aug 18 '14 at 20:18