android获取亮度
① Android中如何控制调节屏幕亮度
/*** 判断是否开启了自动亮度调节*/public static boolean isAutoBrightness(ContentResolver aContentResolver) { boolean automicBrightness = false;try {automicBrightness = Settings.System.getInt(aContentResolver,Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } catch (SettingNotFoundException e) { e.printStackTrace();}return automicBrightness;} 然后就是要觉得当前的亮度了,这个就比较纠结了:/*** 获取屏幕的亮度*/public static int getScreenBrightness(Activity activity) { int nowBrightnessValue = 0; ContentResolver resolver = activity.getContentResolver();try {nowBrightnessValue = android.provider.Settings.System.getInt( resolver, Settings.System.SCREEN_BRIGHTNESS); } catch (Exception e) { e.printStackTrace();}return nowBrightnessValue;} // Settings.System.putInt(activity.getContentResolver(), // Settings.System.SCREEN_BRIGHTNESS_MODE, // Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); lp.screenBrightness = Float.valueOf(brightness) * (1f / 255f); activity.getWindow().setAttributes(lp);} Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);} Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);} 至此,应该说操作亮度的差不多都有了,结束! 哎,本来认为是应该结束了,但是悲剧得是,既然像刚才那样设置的话,只能在当前的activity中有作用,一段退出的时候,会发现毫无作用,悲剧,原来是忘记了保存了。汗!
② 安卓手机有什么软件能增强屏幕亮度,越亮越好
有一个叫(夜间护眼)的,你可以在那里改颜色,我试了一下,屏幕很亮,但是看屏幕已经差不多看不清了。
③ 安卓怎么设置自动调节屏幕亮度
1、屏幕下拉菜单,点击”亮度“调整。
2、亮度“调整为“自动”。
3、或者从“系统设置”进入,点击”亮度“调整。
4、亮度“调整为“自动”。
④ android 应用开发如何调节闪光灯亮度
这是与设备相关的,因为硬件厂商才能自行定义硬件的属性。比如htc为相机闪光灯设置一个亮度文件,通过改写这个文件的值,可以达到变更相机闪光灯的亮度,魅族应该也是这样操作的。作为安卓系统来说,没有统一的解决方案的。
参考htc闪光灯亮度root下的设置方法:
on 2.2 HTC devices you can use it by writing a string to/sys/devices/platform/flashlight.0/leds/flashlight/brightness. This controls if the LED is on and how bright it is. For maximum brightness write "128\n", half brightness write "64\n". Easy to test from adb shell:
⑤ Android亮度调节的几种实现方法
Android亮度调节分为三个层次,分别是:Android系统亮度调节、Android App亮度调节和Android当前屏幕(Window)亮度调节。
1.Android系统亮度调节
Android系统亮度调节全局性最高,常见于系统设置中的亮度设置项。Android中提供了获取和设置系统亮度值(“手动模式下的亮度值”)的接口,具体如下:
// 获取系统亮度
Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
// 设置系统亮度
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS,systemBrightness);
2.Android App亮度调节
与系统亮度不同的是,Android中并未直接提供针对于App层面的亮度调节方式。因此,对于需要进行App的亮度调节,可以通过系统亮度调节或当前屏幕的亮度调节方式间接来实现。
3.Android当前屏幕(Window)亮度调节
Android针对当前屏幕(Window)提供了设置亮度的接口,常见写法如下:Window window = activity.getWindow();WindowManager.LayoutParams lp = window.getAttributes();lp.screenBrightness = brightness;window.setAttributes(lp);
⑥ 怎么让安卓App亮度随系统一致
调整手机亮度即可
1;一般的安卓手机在下拉菜单中可以看到【自动亮度】点击打开,即可实现随系统亮度的效果。
2;如果没有下拉菜单,可以打开【设置】-【显示】-【屏幕亮度】-【自动亮度】
⑦ Android开启自动亮度时,如何获取屏幕实际亮度
调整手机亮度即可 1;一般的安卓手机在下拉菜单中可以看到【自动亮度】点击打开,即可实现随系统亮度的效果。 2;如果没有下拉菜单,可以打开【设置】-【显示】-【屏幕亮度】-【自动亮度】
⑧ android 怎么获得屏幕亮度值 seekbar
一、获取屏幕的亮度
public static int getScreenBrightness(Activity activity) {
int value = 0;
ContentResolver cr = activity.getContentResolver();
try {
value = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
}
return value;
}
二、设置屏幕亮度:
public static void setScreenBrightness(Activity activity, int value) {
WindowManager.LayoutParams params = activity.getWindow().getAttributes();
params.screenBrightness = value / 255f;
activity.getWindow().setAttributes(params);
}
⑨ android代码,怎么监控到屏幕亮度的变化
android的屏幕亮度变化时不会发送广播,而是通过Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, value);设置的,其中的参数value是0-255之间的整型值,如果想获取到当前屏幕的亮度的话,可以通过int currentValue=Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);当然获取到的值也是0-255之间的数,如果你想获取到屏幕亮度的变化可以在Settings.System.putInt()方法中找到Settings.System.SCREEN_BRIGHTNESS_MODE对应的设置语句,然后发送一个广播出去。
⑩ 安卓手机屏幕亮度调节软件
屏幕亮度调节
1.7.2.1
调整
Android
设备的屏幕亮度,调整范围为2~255之间的任意值,并可以在屏幕点亮之后自动还原之前的亮度,也可以锁定亮度禁止其他软件更改。能关闭键盘灯,在晚上很黑的环境下看电子书时,能有好的效果。