Back to project page AdvancedPlayer.
The source code is released under:
Apache License
If you think the Android project AdvancedPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.huilan.library_videoplay.sample; //from w w w . j a v a 2 s .c om import android.app.Activity; import android.content.ContentResolver; import android.content.Context; import android.provider.Settings.System; import android.view.WindowManager; import android.widget.Toast; public class LightnessController { /** * ????????????????? */ public static boolean isAutoBrightness(Context context) { boolean autoBrightness = false; ContentResolver aContentResolver = context.getContentResolver(); try { autoBrightness = System.getInt(aContentResolver, System.SCREEN_BRIGHTNESS_MODE) == System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } catch (Exception e) { Toast.makeText(context, "????????", Toast.LENGTH_SHORT).show(); } return autoBrightness; } /** * ?????? */ public static void setLightness(Activity activity, int value) { try { System.putInt(activity.getContentResolver(), System.SCREEN_BRIGHTNESS, value); WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); lp.screenBrightness = (value <= 0 ? 1 : value) / 255f; activity.getWindow().setAttributes(lp); } catch (Exception e) { Toast.makeText(activity, "????????", Toast.LENGTH_SHORT).show(); } } /** * ?????? */ public static int getLightness(Context context) { return System.getInt(context.getContentResolver(), System.SCREEN_BRIGHTNESS, -1); } /** * ?????????? */ public static void stopAutoBrightness(Context context) { System.putInt(context.getContentResolver(), System.SCREEN_BRIGHTNESS_MODE, System.SCREEN_BRIGHTNESS_MODE_MANUAL); } /** * ?????????? */ public static void startAutoBrightness(Context context) { System.putInt(context.getContentResolver(), System.SCREEN_BRIGHTNESS_MODE, System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC); } }