How to be notified when activity/task changes in A

2019-04-24 22:38发布

I'm building a system status logger. I'd like to be notified when any activity/task is brought to the stop of the stack and becomes visible by the user (not just the one I wrote).

ActivityManager makes it possible to work out what's on top: http://developer.android.com/reference/android/app/ActivityManager.html

however, this requires that I frequently poll to recalculate what's on top wasting a lot of resources. Is there a way to receive an event/callback/notification when an activity changes?

** edit ** To be clear -- I want to be notified when any activity becomes the active activity.

1条回答
祖国的老花朵
2楼-- · 2019-04-24 23:35

onResume() is called when activity comes to live state.

查看更多
登录 后发表回答