How to be notified when activity/task changes in Android

拟墨画扇 提交于 2020-01-23 05:51:05

问题


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:


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



来源:https://stackoverflow.com/questions/7466265/how-to-be-notified-when-activity-task-changes-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!