Hi All,

Is there a proper way to detect when someone leaves your application
(hits the home button or opens a new application from the
notifications bar ... basically the app leaves the foreground) or when
someone enters your application (after hitting the home button).  I
have multiple activities for this app so I cannot use any one activity
lifecycle method because they happen when activities open and close
inside the app and exiting/entering the app.  I also cannot use a
custom application's onCreate method because coming back into the app
after pressing the home button doesn't execute that function.

I was thinking to either track all my activity's onPause, onResume,
and onStop methods because the onResume of the next activity is called
in between the onPause and onStop of the last activity (if i see all
three happen in order within my application then I know that the user
is still in my application) or every time the onPause or onStop method
is called, check the foreground process and see if it's package name
is my app.

Is either one of these better than the other?  Is there a more common/
standard way of doing this?

Tony

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to