2009-09-24 60 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 
}