Java-未找到Android Settings.ACTION_DISPLAY_SETTINGS

前端之家收集整理的这篇文章主要介绍了Java-未找到Android Settings.ACTION_DISPLAY_SETTINGS 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想在活动中调整显示设置.

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

但我得到以下异常:

  1. 09-24 21:24:35.901: ERROR/AndroidRuntime(5892):
  2. android.content.ActivityNotFoundException:
  3. No Activity found to handle Intent
  4. { action=android.settings.DISPLAY_SETTINGS }
最佳答案
你应该 :

  1. try {
  2. final Intent i = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
  3. i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // not sure if needed
  4. startActivity(i);
  5. } catch (ActivityNotFoundException e) {
  6. // not much you can do
  7. }

猜你在找的Android相关文章