>
> I described it in my original post - in short, if the main activity is 
> being paused because the user is leaving the app, a lot of things have to 
> be closed, saved, cleaned up etc.  If it's being paused just to show 
> preferences, those things should not happen.
>

Oh,, i thought you meant you had issue with the event itself.. o 

I'm not keen to make decisions in prefs activity's onPause() (and I'm not 
> doing it yet) but it kind of follows from having to make decisions in the 
> main activity's onPause().  As a simple example, if the main activity is 
> being paused just to show preferences, it doesn't stop music playback. 
>  Now, on pausing the prefs activity, you have to decide - if you're going 
> back to the main activity you leave music playing.  If you're leaving the 
> app entirely, you must stop it.
>

In the example you describe, its rather simple to solve. If you want to 
stop the music when the user leaves the app as in Backs out of it (pressing 
home doesnt count), you should stop it in the onBackPressed of the Main 
activity (pref's have nothing to do with it). If you want to stop it even 
if the user presses Home, then you have several options:
- Check IsFinishing() in Pref's onStop ... a False means the user pressed 
Home, True means the user pressed Back. if its False, stop the music.
- Dont use a different Activity to show Prefs (you can re-use your current 
one, i personally always disliked the PreferencesActivity class.. its ugly 
as fuck)
- Dont make the Pref's activity opaque or full screen. If you can still 
visibly see the Main activity, it would not call onStop... thus it can 
handle the Music on its own and Pref needs not touch it. 
- Or as last choice - Track the amount of onStart activities you have. 
you'll 0 zero when the app is backgrounded, but 1 when you just press Back 
on Prefs.


If that's the case the only solution is to get rid of the 
> PreferenceActivity and make it a law that the app will always be using 
> precisely one Activity - the main one.
> Do you happen to know what it would take to replace PreferenceActivity 
> with a full-screen Dialog?


Try the other choices before going on that route :) Besides, it doesnt have 
to be a dialog... you can either just replace your current contentView or 
use other containers like ViewSwitcher/ViewPager and etc  to switch between 
the main app and the preferences view.  

On Tuesday, March 5, 2013 6:14:42 PM UTC+2, latimerius wrote:
>
> On Tue, Mar 5, 2013 at 4:41 PM, Piren <[email protected] <javascript:>>wrote:
>
>> Not sure what the issues you mention, never had those... onPause/onResume 
>> are pretty much the only lifecycle events that are constant in behavior :)
>>
>>
> I described it in my original post - in short, if the main activity is 
> being paused because the user is leaving the app, a lot of things have to 
> be closed, saved, cleaned up etc.  If it's being paused just to show 
> preferences, those things should not happen.
>  
>
>> The way you describe it, it should be simple, so not sure what you're 
>> missing... I suggest you stop using the Pref's activity onResume/onPause to 
>> decide anything in the app (other than saving the prefs themselves) and 
>> instead base on the Main activity's onStop/onActivityResult
>>
>
> I'm not keen to make decisions in prefs activity's onPause() (and I'm not 
> doing it yet) but it kind of follows from having to make decisions in the 
> main activity's onPause().  As a simple example, if the main activity is 
> being paused just to show preferences, it doesn't stop music playback. 
>  Now, on pausing the prefs activity, you have to decide - if you're going 
> back to the main activity you leave music playing.  If you're leaving the 
> app entirely, you must stop it.
>  
>
>>
>> it can't be that Android application architecture is forced to fall apart 
>>> into a bunch of Activities who can't coordinate among themselves 
>>> efficiently...
>>
>>
>> Thats exactly how android is designed... Android is completely designed 
>> around the fact that each activity is its own "world" and should not depend 
>> on any other activity. Each activity is its own "application".. they state 
>> it several times in their documentation.
>>
>
> If that's the case the only solution is to get rid of the 
> PreferenceActivity and make it a law that the app will always be using 
> precisely one Activity - the main one.
>
> Do you happen to know what it would take to replace PreferenceActivity 
> with a full-screen Dialog?
>
>

-- 
-- 
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
--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to