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之間的任意值,並可以在屏幕點亮之後自動還原之前的亮度,也可以鎖定亮度禁止其他軟體更改。能關閉鍵盤燈,在晚上很黑的環境下看電子書時,能有好的效果。