How to open Android Settings programmatically with Java

How to open Android Settings programmatically with Java

In case your app needs that your user make some changes in the Settings menu i.e to set a default app to open a specific type of files etc, you may like to make this task easier for your user by starting the Settings menu of Android dinamically from your app.

Show system settings

To display the Settings page programmatically, you can use the startActivityForResult method with an Intent object and a constant of the Settings, the following example should open the general settings menu of Android:

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

The usage of the ACTION_SETTINGS constant with startActivityForResult will show system settings. The Settings provider contains global system-level device preferences.

Access specific settings areas

The following list contains all the constants that provide access to different areas of the settings menu:

Note: not all the constants are available on every Android version. In case you need more information visit the official documentation here.

Constants of android.provider.Settings

String ACTION_ACCESSIBILITY_SETTINGS

Activity Action: Show settings for accessibility modules.

String ACTION_ADD_ACCOUNT

Activity Action: Show add account screen for creating a new account.

String ACTION_AIRPLANE_MODE_SETTINGS

Activity Action: Show settings to allow entering/exiting airplane mode.

String ACTION_APN_SETTINGS

Activity Action: Show settings to allow configuration of APNs.

String ACTION_APPLICATION_DETAILS_SETTINGS

Activity Action: Show screen of details about a particular application.

String ACTION_APPLICATION_DEVELOPMENT_SETTINGS

Activity Action: Show settings to allow configuration of application development-related settings.

String ACTION_APPLICATION_SETTINGS

Activity Action: Show settings to allow configuration of application-related settings.

String ACTION_BATTERY_SAVER_SETTINGS

Activity Action: Show battery saver settings.

String ACTION_BLUETOOTH_SETTINGS

Activity Action: Show settings to allow configuration of Bluetooth.

String ACTION_CAPTIONING_SETTINGS

Activity Action: Show settings for video captioning.

String ACTION_CAST_SETTINGS

Activity Action: Show settings to allow configuration of cast endpoints.

String ACTION_DATA_ROAMING_SETTINGS

Activity Action: Show settings for selection of 2G/3G.

String ACTION_DATE_SETTINGS

Activity Action: Show settings to allow configuration of date and time.

String ACTION_DEVICE_INFO_SETTINGS

Activity Action: Show general device information settings (serial number, software version, phone number, etc.).

String ACTION_DISPLAY_SETTINGS

Activity Action: Show settings to allow configuration of display.

String ACTION_DREAM_SETTINGS

Activity Action: Show Daydream settings.

String ACTION_HARD_KEYBOARD_SETTINGS

Activity Action: Show settings to configure the hardware keyboard.

String ACTION_HOME_SETTINGS

Activity Action: Show Home selection settings.

String ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS

Activity Action: Show screen for controlling background data restrictions for a particular application.

String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS

Activity Action: Show screen for controlling which apps can ignore battery optimizations.

String ACTION_INPUT_METHOD_SETTINGS

Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods.

String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS

Activity Action: Show settings to enable/disable input method subtypes.

String ACTION_INTERNAL_STORAGE_SETTINGS

Activity Action: Show settings for internal storage.

String ACTION_LOCALE_SETTINGS

Activity Action: Show settings to allow configuration of locale.

String ACTION_LOCATION_SOURCE_SETTINGS

Activity Action: Show settings to allow configuration of current location sources.

String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS

Activity Action: Show settings to manage all applications.

String ACTION_MANAGE_APPLICATIONS_SETTINGS

Activity Action: Show settings to manage installed applications.

String ACTION_MANAGE_DEFAULT_APPS_SETTINGS

Activity Action: Show Default apps settings.

String ACTION_MANAGE_OVERLAY_PERMISSION

Activity Action: Show screen for controlling which apps can draw on top of other apps.

String ACTION_MANAGE_WRITE_SETTINGS

Activity Action: Show screen for controlling which apps are allowed to write/modify system settings.

String ACTION_MEMORY_CARD_SETTINGS

Activity Action: Show settings for memory card storage.

String ACTION_NETWORK_OPERATOR_SETTINGS

Activity Action: Show settings for selecting the network operator.

String ACTION_NFCSHARING_SETTINGS

Activity Action: Show NFC Sharing settings.

String ACTION_NFC_PAYMENT_SETTINGS

Activity Action: Show NFC Tap & Pay settings

This shows UI that allows the user to configure Tap&Pay settings.

String ACTION_NFC_SETTINGS

Activity Action: Show NFC settings.

String ACTION_NOTIFICATION_LISTENER_SETTINGS

Activity Action: Show Notification listener settings.

String ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS

Activity Action: Show Do Not Disturb access settings.

String ACTION_PRINT_SETTINGS

Activity Action: Show the top level print settings.

String ACTION_PRIVACY_SETTINGS

Activity Action: Show settings to allow configuration of privacy options.

String ACTION_QUICK_LAUNCH_SETTINGS

Activity Action: Show settings to allow configuration of quick launch shortcuts.

String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS

Activity Action: Ask the user to allow an app to ignore battery optimizations (that is, put them on the whitelist of apps shown by ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS).

String ACTION_SEARCH_SETTINGS

Activity Action: Show settings for global search.

String ACTION_SECURITY_SETTINGS

Activity Action: Show settings to allow configuration of security and location privacy.

String ACTION_SETTINGS

Activity Action: Show system settings.

String ACTION_SHOW_REGULATORY_INFO

Activity Action: Show the regulatory information screen for the device.

String ACTION_SOUND_SETTINGS

Activity Action: Show settings to allow configuration of sound and volume.

String ACTION_SYNC_SETTINGS

Activity Action: Show settings to allow configuration of sync settings.

String ACTION_USAGE_ACCESS_SETTINGS

Activity Action: Show settings to control access to usage information.

String ACTION_USER_DICTIONARY_SETTINGS

Activity Action: Show settings to manage the user input dictionary.

String ACTION_VOICE_CONTROL_AIRPLANE_MODE

Activity Action: Modify Airplane mode settings using a voice command.

String ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE

Activity Action: Modify Battery Saver mode setting using a voice command.

String ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE

Activity Action: Modify do not disturb mode settings.

String ACTION_VOICE_INPUT_SETTINGS

Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods.

String ACTION_VPN_SETTINGS

Activity Action: Show settings to allow configuration of VPN.

String ACTION_VR_LISTENER_SETTINGS

Activity Action: Show VR listener settings.

String ACTION_WEBVIEW_SETTINGS

Activity Action: Allows user to select current webview implementation.

String ACTION_WIFI_IP_SETTINGS

Activity Action: Show settings to allow configuration of a static IP address for Wi-Fi.

String ACTION_WIFI_SETTINGS

Activity Action: Show settings to allow configuration of Wi-Fi.

String ACTION_WIRELESS_SETTINGS

Activity Action: Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks.

String AUTHORITY

String EXTRA_ACCOUNT_TYPES

Activity Extra: Limit available options in launched activity based on the given account types.

String EXTRA_AIRPLANE_MODE_ENABLED

Activity Extra: Enable or disable Airplane Mode.

String EXTRA_AUTHORITIES

Activity Extra: Limit available options in launched activity based on the given authority.

String EXTRA_BATTERY_SAVER_MODE_ENABLED

Activity Extra: Enable or disable Battery saver mode.

String EXTRA_DO_NOT_DISTURB_MODE_ENABLED

Activity Extra: Enable or disable Do Not Disturb mode.

String EXTRA_DO_NOT_DISTURB_MODE_MINUTES

Activity Extra: How many minutes to enable do not disturb mode for.

String EXTRA_INPUT_METHOD_ID

String INTENT_CATEGORY_USAGE_ACCESS_CONFIG

Activity Category: Show application settings related to usage access.

String METADATA_USAGE_ACCESS_REASON

Metadata key: Reason for needing usage access.

For example, you can open directly the Language Settings of the device (to change language) executing:

startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS), 0);

With the introduction of new Android APIs, there will be more settings available areas with different constants, read the official documentation of android provider settings here.

Add the permissions if required

For some special areas of the Android Settings, you will need permissions. For example, to open the bluetooth settings you'll need to add the following bluetooth permissions in your app manifest:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

And then you'll be able to open the bluetooth settings:

startActivityForResult(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS), 0);

Otherwise you'll get the following exception:

java.lang.SecurityException: Permission Denial: starting Intent {} requires android.permission.BLUETOOTH_ADMIN

Happy coding !

Become a more social person