You have to use *START_STICKY*<http://developer.android.com/reference/android/app/Service.html#START_STICKY>which is a sticky service, also add flag *FLAG_FROM_BACKGROUND <http://developer.android.com/reference/android/content/Intent.html#FLAG_FROM_BACKGROUND>*while starting your service. when you use START_STICKY make sure you do not pass any data via intent, since your app/activity is killed, but you can re-start the service. Ex : you need to read the values from Sensors and do operations. all the values are generated within the service only.
@Override public int onStartCommand(Intent intent, int flags, int startId) { // We want this service to continue running until it is explicitly stopped, so return sticky. return START_STICKY; } you have to call *stopService(); <http://developer.android.com/reference/android/content/Context.html#stopService%28android.content.Intent%29>*manually to kill the service, else you will use huge memory. -- 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.