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(new Intent(Settings.
Click File > Settings (on macOS, Android Studio > Preferences) to open the Settings dialog.
Getting to Your Settings There are two ways to get to your phone's settings. You can swipe down on the notification bar at the top of your phone display, then tap on the top right account icon, then tap on Settings. Or you can tap on the “all apps” app tray icon in the bottom middle of your home screen.
You can open with
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
You can return by pressing back button on device.
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.
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.
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.
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
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