Tuesday, March 5, 2013

[android-developers] Re: how to tell why Activity.onPause() is called

Use http://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint()

Gets called only when the user has decided to leave instead of another app coming in the foreground.

On Monday, March 4, 2013 3:14:29 PM UTC-8, latimerius wrote:
Hello,

I would like to be able to tell if Activity.onPause() was called because the user is leaving the app, or simply because another Activity within the same app is coming up.

I have a main Activity and a PreferenceActivity.  The main Activity needs to handle onPause() differently depending on why it's called.  If the user is leaving the app, it needs to stop helper threads, close various things like analytics session, deal with GL, save data to SD card etc.  However, if onPause() is just to display prefs most of that should happen, and a bunch of other things should be done instead.

I'm wondering if there's a framework-supported way to handle this, or at least an idiomatic solution, as in a (semi)standard way of managing an Activity with heavy set-up and tear-down?

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment