How can I open settings programmatically?
12 Answers
You can open with
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
You can return by pressing back button on device.

- 4,044
- 2
- 23
- 28
-
any way to get back when user pressed Clear Cache button ? – SweetWisher ツ Nov 28 '14 at 05:09
-
1@SweetWisherヅ You just have to edit the source code. – Behnam Feb 14 '15 at 05:17
-
2Now 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. Just write Settings. and Android Studio will show you all categories in autocomplete. – Asim Gasimzade Feb 06 '18 at 11:39
-
2Can I search a particular setting within Settings App and open that particular setting programmatically from my App? e.g. can I search OTG from my app in Settings of the phone? – Divya Gupta Jan 24 '20 at 10:40
-
It seems to me using StartActivity is enough, I get always get the result CANCELD when coming back to the App (which is normal when coming back with back button). Thus the app is not notified of changed settings this way. – this.myself Mar 17 '20 at 15:15
-
@kjurkovic can you please explain why there is need to startActivityForResult, You can simply open setting app using ===> startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS)); – The Black Horse Apr 24 '20 at 15:23
-
As this code opens settings in the same window, it can mess up the functionality of your app. Use the code from [this anwer](https://stackoverflow.com/a/62092663/12787264) to prevent that. – finnmglas May 29 '20 at 18:45
-
@TheBlackHorse because with startActivityForResult you can do some checks if you need to when you come back to app from settings in `onActivityResult` method. It works with startActivity as well. @finnmglas Android doesn't have windows. It has activities - since settings is a separate app, with it's own activities, makes what you say totally stupid – kjurkovic Jun 01 '20 at 15:37
I used the code from the most upvoted answer:
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
It opens the device settings in the same window, thus got the users of my android application (finnmglas/Launcher) for android stuck in there.
The answer for 2020 and beyond (in Kotlin):
startActivity(Intent(Settings.ACTION_SETTINGS))
It works in my app, should also be working in yours without any unwanted consequences.
-
3Thanks friend, please update your code like this: startActivity(new Intent(Settings.ACTION_SETTINGS)); – Muhammad Ali Jun 30 '20 at 05:51
-
4
-
7
-
1I really love the 2020 solution as it enables you to easily open a specific category of the settings like the accessibility settings by simply using `Settings.ACTION_ACCESSIBILITY_SETTINGS` – Mohamed Medhat Mar 13 '22 at 08:57
This did it for me
Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(callGPSSettingIntent);
When they press back it goes back to my app.

- 6,096
- 7
- 51
- 88
-
1
-
2@IgorGanapolsky it opens Location based settings inside the " Setting " – androminor Apr 14 '20 at 03:39
You can try to call:
startActivityForResult(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
for other screen in setting screen, you can go to
https://developer.android.com/reference/android/provider/Settings.html
Hope help you in this case.

- 5,593
- 38
- 51

- 243
- 3
- 5
-
2You require to pass "REQUEST_CODE" as 2nd argument of `startActivityForResult`. – Chintan Rathod Sep 13 '17 at 08:30
-
Besides, he asked for General Settings. Not for Wifi settings. So why did you answer that? – james04 Sep 18 '22 at 12:20
In case anyone finds this question and you want to open up settings for your specific application:
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:" + context.packageName)
startActivity(intent)

- 2,635
- 20
- 23
Check out the Programmatically Displaying the Settings Page
startActivity(context, new Intent(Settings.ACTION_SETTINGS), /*options:*/ null);
In general, you use the predefined constant Settings.ACTION__SETTINGS
. The full list can be found here

- 337
- 4
- 7

- 29,068
- 10
- 64
- 102
-
1Is there a way to open the settings into the new option: "Control which applications can read your notifications" (added in API 18)? – Javi Mar 05 '14 at 17:04
To achieve this just use an Intent using the constant ACTION_SETTINGS, specifically defined to show the System Settings:
startActivity(new Intent(Settings.ACTION_SETTINGS));
startActivityForResult() is optional, only if you want to return some data when the settings activity is closed.
startActivityForResult(new Intent(Settings.ACTION_SETTINGS), 0);
here you can find a list of contants to show specific settings or details of an aplication.

- 124,308
- 23
- 334
- 268
You can make another class for doing this kind of activities.
public class Go {
public void Setting(Context context)
{
Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}

- 4,391
- 1
- 33
- 39
Use this intent to open security and location screen in settings app of android device
startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));

- 627
- 4
- 7
Following the new api described on: https://developer.android.com/training/permissions/requesting
private val goToSettingsRequest = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { activityResult ->
// TODO: DEAL WITH THE CALLBACK
}
private fun goToSettings() {
goToSettingsRequest.launch(Intent(Settings.ACTION_SETTINGS))
}

- 1,709
- 16
- 22
Send User to Settings With located Package, example for WRITE_SETTINGS permission:
startActivityForResult(new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS).setData(Uri.parse("package:"+getPackageName()) ),0);

- 1,578
- 2
- 10
- 9
open android location setting programmatically using alert dialog
AlertDialog.Builder alertDialog = new AlertDialog.Builder(YourActivity.this);
alertDialog.setTitle("Enable Location");
alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
});
alertDialog.show();

- 1,969
- 17
- 17