How can I disable settings option in android, I dont want user to get into it. I have launched home intent when settings process is running but its not seems to be good. Any other way to do it ?
The most you can do is take advantage of Device Administration, introduced in 2.2, to enforce settings policies. Details here
Related
I want to create an application that will turn on and off power saver mode within itself programmatically with on a button click using android-Kotlin.
I have tried using the intent filter, but it goes to system settings, and then we turn it on or off manually.
code :-
buttonBatterySave.setOnClickListener {
beep() //sound effect
val batterySaverIntent = Intent()
batterySaverIntent.component = ComponentName(
"com.android.settings",
"com.android.settings.Settings\$BatterySaverSettingsActivity"
)
startActivityForResult(batterySaverIntent, 0)
}
I just want my application to turn on or off by itself within the application with a single button click.
Thank you
As of Android 9 the Power management was changed. They use a bucket style procedure that changes according to Android docs. So if you did invoke the power saver in app, then it may not work again on the next app run. So the safest route is to take the user to settings.
You can see the power manager docs here on android developer https://developer.android.com/about/versions/pie/power
To your question is it possible? Yes it is possible but not advised with the new procedure. If your app is in the same bucket that get turned off during power save then your app won’t be able to turn it back on. You would then have to go into settings, power management and then turn the battery saver off in order to use your app again.
This is what Android Docs on power management explains. So the best option is to let the user turn it on off through settings, and leave the system settings alone when it comes to the core programming language of the device.
I do not want the user to open device settings, so I need to disable device settings.
I found way to open settings
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
But I am looking for a way to disable it, how can I do that?
You can not disable system packages unless you make a custom rom. Besides that it is a huge security risk to allow developers to disable settings so the user can not stop the app.
You may create custom launcher with kiosk mode to achieve your target. Note that this approach requires some actions from your users.
Related links
https://developer.android.com/work/cosu.html
http://pvolan.blogspot.ru/2017/01/android-50-kiosk-mode-aka-super.html
Sadly, now we can no more map our apps to Long press home button Event. But, There is a settings page where it is possible to change the default device assistance app:
Default Device Assistance app on Samsung
Is it anyway possible to change the default device assistance app programmatically or even launch the settings page (via intent) to make the user change the setting?
Is it anyway possible to change the default device assistance app programmatically
Fortunately, no, for blindingly obvious privacy and security reasons.
even launch the settings page (via intent) to make the user change the setting?
Ideally, there would be an action in Settings for this, but I do not see one that looks like it is specific to the assistant.
Correct me if I am wrong:
1) You cannot programatically turn GPS On/Off on all versions of Android. Maybe some previous versions, and some hacks, but not on all devices. It simply is not allowed.
This leaves only two options:
1) Use new Google Play Services to prompt user to change these settings.
One issue with this is what if you just want to allow user to turn on GPS,
but not WIFI? The resolver will give them options to turn on both. How
can you just turn on one but not the other?
2) Send user to the settings application by firing off an Intent.
Now with 1) User must have current google play services installed.
If not they can be prompted to install it via standard GPS dialog.
Ok, now for 2) Sending user to settings application. I have the following problem:
When I fire off this intent, they not only get to change the Location/GPS Settings but they can also hit the little back button within Settings app, and adjust all settings. Is there any way to prevent this? Anyway to bring up the Location/GPS Settings without the inner back button? Thanks.
You cannot programatically turn GPS On/Off on all versions of Android. Maybe some previous versions, and some hacks, but not on all devices. It simply is not allowed.
Correct, for obvious privacy reasons.
When I fire off this intent, they not only get to change the GPS Settings but they can also hit the little back button within Settings app, and adjust all settings. Is there any way to prevent this?
No.
How can I set a system app (my custom system app) to be NOT DISABLED?
Just like the Launcher or Settings that the "Disable" button is not enabled. So the user can't disable my system app.
Below is the Launcher's effect:
It's not possible for a third party application (like yours) to define itself as not being possible to disable- It's important that the user be able to disable any application on their system. If you find a way, that will be considered a security flaw, and it'll likely be disabled in the next release of Android :)
Launcher and Settings are special cases in terms of not being possible to disable, since disabling those would make it difficult/impossible for the user to maintain their own device (or to undo their decision, since they wouldn't be able to launch the settings Activity and re-enable it).