[android-developers] Extended Application life time.

2012-02-15 Thread Anieeh
hi all
I have extended application class and in that i have kept an model
object for global access which is single ton class and i have a
service which runs continuously in background when no activity is
running. And this background service uses that model object kept in
Application class.

Is our application instance will remain in memory when no activity is
running and our service is running in background? or application
object killed and our service will run continuously . so that Service
will get the model object from Application.

Thanks
  Anieeh

-- 
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


Re: [android-developers] Extended Application life time.

2012-02-15 Thread Mark Murphy
On Wed, Feb 15, 2012 at 8:50 AM, Anieeh animesh.andr...@gmail.com wrote:
 i have a
 service which runs continuously in background when no activity is
 running.

This is not generally a good idea, unless the user specifically
requested it (e.g., music player). Users think developers who create
everlasting services are morons and go to great lengths to attack such
apps with task killers, force stop in Settings, etc.

 And this background service uses that model object kept in
 Application class.

 Is our application instance will remain in memory when no activity is
 running and our service is running in background?

Until the user or Android terminates your process, yes.

 or application
 object killed and our service will run continuously . so that Service
 will get the model object from Application.

The Application object only goes away when the process does.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 4.1 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