2013-08-19 1 views
0

내 앱에서 버튼을 클릭하면 call the Brightness classAndroid system settings에 있음 (사용자가 설정> 표시> 밝기로 이동할 때 표시됨)). 이 밝기 클래스를 호출하는 것을 직관적 인 것 같다, 그래서Android : "BrightnessPreference"클래스를 호출 할 수 없음 (com.android.settings 패키지)

Intent brightness = new Intent(); 
brightness.setClassName("com.android.settings", "com.android.settings.DisplaySettings"); 
startActivity(brightness); 

, 하나는 대체해야

는 그이 (가) Display class (있는 밝기 클래스가 발견) 나는 다음과 같은 코드를 사용할 수 있습니다 전화를 알고 다음과 같이 ( this link에서 볼 때 모두 동일한 위치에 저장되기 때문에) "DisplaySettings"에 대한 "BrightnessPreference"

그러나
Intent brightness = new Intent(); 
brightness.setClassName("com.android.settings", "com.android.settings.BrightnessPreference"); 
startActivity(brightness); 

, 내 에뮬레이터, it force closes에이 코드를 실행하려고 할 때. 어떤 이유로 볼 수 없거나 calling BrightnessPreference이 아닙니까?

답변

0

BrightnessPreference는 Preference 클래스를 확장합니다. 당신이 일을하려고하는 것은 나를 따라 의도를 사용하여 활동으로 열려으로 docs

Preference class provides the View to be displayed in the activity

에 따르면

수 없습니다.

그림과 같이 프로그래밍 방식으로 설정할 수 있습니다. here