Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return automicBrightness;
}
//停止亮度调节
public static void stopAutoBrightness(Activity activity){
//设置Activity亮度手工模式
Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
接下来获取手机当前亮度,要通过Context来使用内容提供器getContentResolver()
再用android.provider.Settings.System.getInt(
resolver,Settings.System.SCREEN_BRIGHTNESS)来得到亮度
//获取亮度
public static int getScreenBrightness(Activity activity){
int nowBrightnessValue = 0; //当前亮度
//通过ContentResolver接口访问provider数据,获得实例
ContentResolver resolver = activity.getContentResolver();
try {
nowBrightne