How to get all running activities android?
I was wondering is there a way of g开发者_StackOverflowetting a list with all running activities ?
As far as I understand there will only one activity running at a time that will be your active activity on screen, other activities will be in paused or Stopped state if any.
No, as far as I know there is no built in way to get a list of running activities (assuming running - means non-destroyed activities).
If you only need a list of activities in your application, you can create some kind of "registrar" mechanism, so each activity registers in onCreate()
and unregisters in onDestroy()
. This should be some singleton class, because it should automatically be "cleared" if application is killed (as opposed to storing list of active activities in DB).
精彩评论