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?