2009-09-24 56 views
3

我想调整我的活动中的显示设置。Android Settings.ACTION_DISPLAY_SETTINGS找不到

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

但我得到以下异常:

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

回答

1

意图Settings.ACTION_DISPLAY_SETTINGS与Android SDK 1.6工作正常。 [ATLEAST我。]
但随后documentation状态
“在某些情况下,匹配的活动可能不存在,所以确保你防范这一点。”

2

您应该:

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 
}