Created
October 1, 2013 22:12
-
-
Save melihmucuk/6786011 to your computer and use it in GitHub Desktop.
Programmatically changing screen brightness on Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| boolean ScreenBrightness(int level, Context context) { | |
| try { | |
| android.provider.Settings.System.putInt( | |
| context.getContentResolver(), | |
| android.provider.Settings.System.SCREEN_BRIGHTNESS, level); | |
| android.provider.Settings.System.putInt(context.getContentResolver(), | |
| android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE, | |
| android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); | |
| android.provider.Settings.System.putInt( | |
| context.getContentResolver(), | |
| android.provider.Settings.System.SCREEN_BRIGHTNESS, | |
| level); | |
| return true; | |
| } | |
| catch (Exception e) { | |
| Log.e("Screen Brightness", "error changing screen brightness"); | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment