Can I listen to changes in the activity stack

1.1k views Asked by At

It has been asked before but never got an answer: I want to know when a certain 3rd party activity (the browser) is in the foreground and when it is not in the foreground anymore. I know how to check which activity is in the foreground, but how do I listen to changes in the activity stack.

Any other idea is welcome.

1

There are 1 answers

0
David Wasser On BEST ANSWER

There aren't any events broadcast that you could listen for. The only way to do this would be to continuously monitor the foreground task using ActivityManager.getRunningTasks() and check for changes in topActivity in the foreground task.