I'm using a sticky android service by using code snippet in service class
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
But it restarts only when app get force closed by android o/s, Although when user force stop app from application manager, service also get terminated. However, my requirement is that I want to keep running service forever till app is installed in device. Could any one help me on this?
Going through long research and blogs recommendation, if user click force close application from application manger, then there is no way to restart again automatically.
Though, there can be work around to start stopped service by following broadcasts like - Usb detection, bluetooth status change, device restart etc. In these cases device send broadcast and if your app is capable to receive these notification, you can restart your service from context received in broadcast.