[android-developers] Re: Recognising when an app is "closed"
mcswd01, You also might take a look at using the onDestroy() event of the first/ main Activity. onDestroy for the main activity will only get called if you hit back from that activity of call finish() for that activity. I think this is what you are looking for. On Jan 17, 10:13 am, mscwd01 wrote: > Okay, I'll have to opt for the stop/start approach each time you > switch from Activity to Activity - its not a very elegant solution > though. > > Im suprised theres not a "whole application has lost focus".onPause(). > > On Jan 17, 3:27 pm, Mark Murphy wrote: > > > mscwd01 wrote: > > > Isn't onPause() called when one Activity calls another too? > > > Sure. > > > > I want to know when an entire Activity has lost focus, > > > What is "an entire Activity"? > > > > if I use onPause > > > () in an Activity which calls another, when the other Activity has > > > started the initiating Activity's onPause() method is called. > > > Correct. Suspend network activity on every onPause(); re-enable network > > processing on every onResume(). Then, if any activity is active, network > > processing is in operation; if all are paused, network processing is > > stopped. > > > If by "an entire Activity" you really mean "an entire application", so > > long as all the components are in the same process, and so long as you > > use loose coupling so garbage collection isn't impeded, you can > > communicate among collaborating activities however you wish. > > > -- > > Mark Murphy (a Commons Guy)http://commonsware.com > > _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Recognising when an app is "closed"
On Sat, Jan 17, 2009 at 8:13 AM, mscwd01 wrote: > Im suprised theres not a "whole application has lost focus".onPause(). Well in Android there isn't really a strong concept of an "application" in general. For example, when the user clicks on a button to pick an image for something in your app and goes into the image gallery to select it... have they left your application? It depends on how you look at it. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Recognising when an app is "closed"
Wouldn't onStop() be a better solution since it gets called when the app is no longer in focus? >From the doc: Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one. This may happen either because a new activity is being started, an existing one is being brought in front of this one, or this one is being destroyed. On Jan 17, 4:13 pm, mscwd01 wrote: > Okay, I'll have to opt for the stop/start approach each time you > switch from Activity to Activity - its not a very elegant solution > though. > > Im suprised theres not a "whole application has lost focus".onPause(). > > On Jan 17, 3:27 pm, Mark Murphy wrote: > > > mscwd01 wrote: > > > Isn't onPause() called when one Activity calls another too? > > > Sure. > > > > I want to know when an entire Activity has lost focus, > > > What is "an entire Activity"? > > > > if I use onPause > > > () in an Activity which calls another, when the other Activity has > > > started the initiating Activity's onPause() method is called. > > > Correct. Suspend network activity on every onPause(); re-enable network > > processing on every onResume(). Then, if any activity is active, network > > processing is in operation; if all are paused, network processing is > > stopped. > > > If by "an entire Activity" you really mean "an entire application", so > > long as all the components are in the same process, and so long as you > > use loose coupling so garbage collection isn't impeded, you can > > communicate among collaborating activities however you wish. > > > -- > > Mark Murphy (a Commons Guy)http://commonsware.com > > _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Recognising when an app is "closed"
Okay, I'll have to opt for the stop/start approach each time you switch from Activity to Activity - its not a very elegant solution though. Im suprised theres not a "whole application has lost focus".onPause(). On Jan 17, 3:27 pm, Mark Murphy wrote: > mscwd01 wrote: > > Isn't onPause() called when one Activity calls another too? > > Sure. > > > I want to know when an entire Activity has lost focus, > > What is "an entire Activity"? > > > if I use onPause > > () in an Activity which calls another, when the other Activity has > > started the initiating Activity's onPause() method is called. > > Correct. Suspend network activity on every onPause(); re-enable network > processing on every onResume(). Then, if any activity is active, network > processing is in operation; if all are paused, network processing is > stopped. > > If by "an entire Activity" you really mean "an entire application", so > long as all the components are in the same process, and so long as you > use loose coupling so garbage collection isn't impeded, you can > communicate among collaborating activities however you wish. > > -- > Mark Murphy (a Commons Guy)http://commonsware.com > _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Recognising when an app is "closed"
mscwd01 wrote: > Isn't onPause() called when one Activity calls another too? Sure. > I want to know when an entire Activity has lost focus, What is "an entire Activity"? > if I use onPause > () in an Activity which calls another, when the other Activity has > started the initiating Activity's onPause() method is called. Correct. Suspend network activity on every onPause(); re-enable network processing on every onResume(). Then, if any activity is active, network processing is in operation; if all are paused, network processing is stopped. If by "an entire Activity" you really mean "an entire application", so long as all the components are in the same process, and so long as you use loose coupling so garbage collection isn't impeded, you can communicate among collaborating activities however you wish. -- Mark Murphy (a Commons Guy) http://commonsware.com _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Recognising when an app is "closed"
Isn't onPause() called when one Activity calls another too? I want to know when an entire Activity has lost focus, if I use onPause () in an Activity which calls another, when the other Activity has started the initiating Activity's onPause() method is called. On Jan 17, 1:03 pm, Mark Murphy wrote: > mscwd01 wrote: > > I may just be overlooking something blatently obvious here but this > > seems to be alluding me... > > > I have an app which routinely contacts my server requesting updates > > (small amounts of data). Whilst the user is using my app I wish this > > updating to continue, however when the app "closes" (i.e. the "home" > > button is pressed and the app loses focus), I wish to stop the app > > requesting updates from the server... simply because its unnecessary. > > I realise an app is not actually "closed" when the home button is > > pressed, however is there a method called which signifies a user has > > "left" the application and started another/returned to the home > > screen? > > onPause() > > -- > Mark Murphy (a Commons Guy)http://commonsware.com > > Android Training on the Ranch! -- Mar 16-20, > 2009http://www.bignerdranch.com/schedule.shtml --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Recognising when an app is "closed"
mscwd01 wrote: > I may just be overlooking something blatently obvious here but this > seems to be alluding me... > > I have an app which routinely contacts my server requesting updates > (small amounts of data). Whilst the user is using my app I wish this > updating to continue, however when the app "closes" (i.e. the "home" > button is pressed and the app loses focus), I wish to stop the app > requesting updates from the server... simply because its unnecessary. > I realise an app is not actually "closed" when the home button is > pressed, however is there a method called which signifies a user has > "left" the application and started another/returned to the home > screen? onPause() -- Mark Murphy (a Commons Guy) http://commonsware.com Android Training on the Ranch! -- Mar 16-20, 2009 http://www.bignerdranch.com/schedule.shtml --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---