I have enabled service in my AndroidManifest.xml. And I want to disable it from my code:
getPackageManager().setComponentEnabledSetting(
serviceName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
If I disable the service like above, will it be disabled forever? Or not?
Yes, settings are persistent until reinstall (delete application, install again) or new value is set again with setComponentEnabledSetting()
. Additionally, as a border case, someone with super-user privileges can reset your app.
Please read this answer for details.
It will be disabled until you enable it or the user uninstalls your app.
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