Android的短屏幕亮度code! [英] Android short screen brightness code!

查看:108
本文介绍了Android的短屏幕亮度code!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何谁知道为什么这code没有降低我的应用程序的背光?

 上下文语境=这一点;

    Settings.System.putInt(co​​ntext.getContentResolver(),
    Settings.System.SCREEN_BRIGHTNESS,255);
 

解决方案

应用程序不再允许修改全局亮度。不要使用人曾试图想出在各个点的招数,这些使用私有的API,并在不同设备间多种方式破解(和被认为已经关闭了较新版本的平台的安全漏洞)。

官方API设置亮度是WindowManager.LayoutParams.screenBrightness,它可以让你设置亮度为自己的应用程序的窗口。该平台将自动改变亮度的照顾,用户在进出你的应用程序的移动。

使用此选项可以更改它:

  WindowManager.LayoutParams LP = getWindow()的getAttributes()。
lp.screenBrightness =&所述; 0和1之间&GT一些值;;
。getWindow()setAttributes(LP);
 

Anyone who knows why this code ain't lowering the backlight of my application?

Context context = this;

    Settings.System.putInt(context.getContentResolver(),
    Settings.System.SCREEN_BRIGHTNESS, 255);

解决方案

Applications are no longer allowed to modify the global brightness. Don't use the tricks people have tried to come up with at various points, these use private APIs and will break in various ways across different devices (and are considered security holes that have been closed on more recent versions of the platform).

The official API to set the brightness is with WindowManager.LayoutParams.screenBrightness, which lets you set the brightness for your own app's window. The platform will automatically take care of changing the brightness as the user moves in and out of your app.

Use this to change it:

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = <some value between 0 and 1>;
getWindow().setAttributes(lp);

这篇关于Android的短屏幕亮度code!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆