Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access device settings programmatically?

Tags:

android

Is there any way to access device settings programmatically?

For Example: Settings > Developer Options > USB debugging > True/False

Thanks in advance.

Edit: USB debugging is just an example. Can I access every settings which is exist in Settings in device.

like image 321
auy Avatar asked Aug 16 '12 10:08

auy


People also ask

How do I get to programmatically in Android settings?

Now you can use Intent intent = new Intent(android. provider. Settings. ACTION_SECURITY_SETTINGS); startActivity(intent); There are whole bunch of constants for every main settings category that you can choose from.

How do I access settings in Android Studio?

Click File > Settings (on macOS, Android Studio > Preferences) to open the Settings dialog.

How do I open location settings in android programmatically?

Get current location settingsTask<LocationSettingsResponse> task = client. checkLocationSettings(builder. build()); When the Task completes, your app can check the location settings by looking at the status code from the LocationSettingsResponse object.

How can I programmatically open the permission screen for a specific app?

Is it possible to display the "App Permissions" screen for a specific app via an Intent or something similar? It is possible to display the app's "App Info" screen in Settings with the following code: startActivity( new Intent( android. provider.


1 Answers

Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1);

But you need root access to do this. Only system apps have permission to change secure settings

Edit: Try this to Show all ANRs

Settings.Secure.putInt(ContentResolver,Settings.Secure.ANR_SHOW_BACKGROUND,0);

and for Don't keep activities

ActivityManagerNative.getDefault().setAlwaysFinish(true)

but ActivityManagerNative is hidden in standard api set. you will need to do either reflection or use this method to get android.jar. Again I guess this needs root access

like image 145
nandeesh Avatar answered Sep 23 '22 23:09

nandeesh