On Tue, Mar 5, 2013 at 12:13 PM, Piren <gpi...@gmail.com> wrote: > The obvious way, since it's your app.. just keep a flag saying "im > starting an activity" whenever you start the prefs one... >
Yes, that's what I'm doing at the moment. However, it's getting kludgy fairly fast. One problem is deciding what to do when now the PreferenceActivity gets onPause(). If it's because the user decided to leave the app (e.g. pressed Home while in prefs), the prefs Activity has to remember the main Activity has not actually paused properly (as it knew it was only getting onPause() to display prefs) and has to make sure to finish the pausing. However, if the prefs get onPause() because the user pushed Back to return to the main Activity, it doesn't have to do anything in particular. So now it's the prefs Activity who needs to understand why it's being paused. Except that now it's a bit harder. When the prefs Activity is being displayed, it's because the user pushed a button in the main Activity, so the main Activity knows for sure preferences are coming up. The PreferenceActivity has no such thing as a "Return to main Activity" button" as the only possible way the user could ever leave prefs and return to main. Sure, I can monitor Back presses - if Back was pushed before onPause() we're probably returning to the main Activity, if not we're probably leaving the app altogether. The keyword here being "probably" though as AFAIK this is not officially documented anywhere. So it smells like relying on undocumented behaviour (not that it matters much on Android if you rely on documented or undocumented ;-)). While trying to figure out whether Back is the only way of returning from prefs to main (and also, has it always been so? will it stay that way in the next Android version?) and googling for an answer I realised I'm not the first or only one who's trying to solve this. That's why I'm wondering, if there is a reasonably elegant and standard way of arranging things to solve these problems. -- -- 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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.