Android Settings.ACTION_DISPLAY_SETTINGS not found

I want to adjust the display options in my activity.

Intent intent = new Intent (Settings.ACTION_DISPLAY_SETTINGS);             
startActivity (intent);

but I get the following exception:

09-24 21:24:35.901: ERROR/AndroidRuntime(5892): 
android.content.ActivityNotFoundException: 
    No Activity found to handle Intent 
        { action=android.settings.DISPLAY_SETTINGS }
+3
source share
2 answers

You must:

try {
    final Intent i = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // not sure if needed
    startActivity(i);
} catch (ActivityNotFoundException e) {
    // not much you can do
}
+2
source

Intent Settings.ACTION_DISPLAY_SETTINGS works great with Android SDK 1.6 . [At least for me.]
But then the documentation states that "In some cases, the corresponding activity may not exist, so make sure you protect it."

+1

Source: https://habr.com/ru/post/1718498/


All Articles