您可以設置屏幕亮度按鈕,單擊
第一種方式:
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
int curBrightnessValue=android.provider.Settings.System.getInt(
getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS);
setBrightness(curBrightnessValue-25);//set BRIGHTNESS
}
private void setBrightness(int brightness) {
try {
IHardwareService hardware = IHardwareService.Stub.asInterface(
ServiceManager.getService("hardware"));
if (hardware != null) {
hardware.setScreenBacklight(brightness);
}
} catch (RemoteException doe) {
}
的Manifest.xml
<uses-permission android:name="android.permission.HARDWARE_TEST"></uses-permission>
方式二:
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
int curBrightnessValue=android.provider.Settings.System.getInt(
getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS);
int SysBackLightValue = curBrightnessValue-25;
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS,
SysBackLightValue);
}
周
的AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
請發表您的代碼。直到我們看到錯誤的地方 – mondieki