Hello,
I have some proccess that i would like to run in the background the whole time. so i made it "service". my question is: is there anyway to prevent from the user to kill this service? (even if he uses third party app)
thanks,
ray.
Hello,
I have some proccess that i would like to run in the background the whole time. so i made it "service". my question is: is there anyway to prevent from the user to kill this service? (even if he uses third party app)
thanks,
ray.
Maybe this can help you:
final Intent intent = new Intent(context, YourService.class);
final PendingIntent pending = PendingIntent.getService(context, 0, intent, 0);
final AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pending);
long interval = 30000;//milliseconds
alarm.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),interval, pending);
This way your service will be receiving regular onStart events from AlarmManager. If your service is stopped it will be restarted. So you may say it will be running infinitely. More complete sample can be found in Photostream sample application http://code.google.com/p/apps-for-android/.