7

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.

user48956
  • 14,850
  • 19
  • 93
  • 154

1 Answers1

0

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

dinesh707
  • 12,106
  • 22
  • 84
  • 134
  • Sorry -- I should have been more clear in my question. I want to know of *any* Android activity has come to the top of the stack, not just one I wrote myself. – user48956 Sep 19 '11 at 13:59
  • If something else come on top of your application your application/activity calls "onPause()" method. By that you can find something else has come to live state. – dinesh707 Sep 20 '11 at 06:57
  • I don't really care about changes in the state of my activity. I want to know when onPause/onResume is called in *all other* activities. – user48956 Sep 21 '11 at 05:05
  • what do you mean by "I want to know". I believe that is your app. So your app can know something else is running when the Android OS makes your app paused. – dinesh707 Sep 21 '11 at 06:33
  • I would like my process to be notified when any process obtains or loses the foreground status (i.e. when any process becomes, or is no longer, the topmost activity). – user48956 Sep 26 '11 at 00:18