我创建了自动亮度设置changed.here的切换按钮我想知道关于自动亮度是开还是关的状态如果它是开的状态切换按钮将是关的,如果它是开的切换按钮将是关的,这里怎么做
请帮帮我
发布于 2015-09-23 01:09:15
int brightnessmode;
getBrightMode();
if(brightnessmode==1){
//below code will off the auto mode
android.provider.Settings.System.putInt(contentresolver, Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
//Here perform any action you want
}
if(brightnessmode==0){
//below code will on the auto mode
android.provider.Settings.System.putInt(contentresolver, Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
//Here perform any action you want
}
//This method will give brightness mode
//if brigthnessmode=0 means Auto mode is currently off
//if brightnessmode=1 means Auto mode is currently on
protected void getBrightMode() {
// TODO Auto-generated method stub
try {
brightnessmode = System.getInt(contentresolver, System.SCREEN_BRIGHTNESS_MODE);
} catch (Exception e) {
Log.d("tag", e.toString());
}
}发布于 2015-02-27 16:23:40
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);使用SCREEN_BRIGHTNESS_MODE模式http://developer.android.com/reference/android/provider/Settings.System.html
发布于 2011-07-20 14:52:02
您应该能够从Settings.System中读取此内容,查找SCREEN_BRIGHTNESS_MODE
https://stackoverflow.com/questions/6757728
复制相似问题