If it is normal for your process to be killed (along with singleton) immediately after the user leaves his activity, then use singleton. If you need it to continue to work for a while after this, use the service. If you want to continue working after the user leaves him, but you can not live with him because the user is now connected to something else where more memory is required, then use singleton.
The solution between the two only comes down to the life cycle of your application. For this purpose, this is a service - ask the platform to change the management of your process. If you need context in singleton mode, just use Context.getApplicationContext () to retrieve the global context for your process.
hackbod Aug 25 '10 at 16:45 2010-08-25 16:45
source share