How to set a certain percentage of screen brightness in the application? For example, 30%.
2 answers
Add a line with resolution in the AndroidManifest.xml manifest:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/> Code to change the brightness:
Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, value); An example with a sikbar that changes the brightness of the screen.
enSO .
- But your answer helped me a lot, thanks! - GuardFromUA 2:21 pm
|
Does not see permission in the manifesto ... Strange. This code helped:
WindowManager.LayoutParams layout = getWindow().getAttributes(); layout.screenBrightness = 0.3F; getWindow().setAttributes(layout); The downside of it is that you need to enter in each activation.
|