I'm making a service on Android where it will be installed on a phone/tablet. Many people can use that tablet but only selected ones should have right to close the service. How can I achieve this? I googled & found some options:
NEW OPTION:
I have another idea to make it work : I'm will make it system app so that it will warn user when he tries to stop it. For system apps, when user presses the "stop" button from settings, a warning message pops up :" Closing this app may lead to..(blah blah)....". Do you know which intent is thrown to pop up this message? I think I can use that intent here and disable the "OK" option in this message
.
Even if the user couldn't stop the service, the phone could still get powered off, run out of battery, or lose network connectivity. It's even conceivable that Android could kill the service process if it ran low on resources. So the code should be prepared to for handling the potential data loss in those events.
I'm not certain how you detect when the service has been stopped, but there's always AlarmManager for periodic polling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With