改变屏幕亮度以编程方式在机器人 [英] changing screen brightness programmatically in android

查看:133
本文介绍了改变屏幕亮度以编程方式在机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式更改屏幕亮度的机器人。 目前,我用这个code:

I want to change the screen brightness programmatically in android. At the moment I use this code:

WindowManager.LayoutParams lp = getWindow().getAttributes();
float brightness=1.0f;
lp.screenBrightness = brightness;
getWindow().setAttributes(lp);

但这个样品code适用于蛋糕,而不是最新版本。我使用的是最新版本的SDK。什么是新的Andr​​oid版本的preferred解决方案?

But this sample code works on cupcake, not on latest versions. I am using the latest version of SDK.. What is the preferred solution for newer Android Versions?

推荐答案

如何使用IHardwareService接口呢?一个例子可以在此找到教程

How about using the IHardwareService interface for this? An example can be found in this tutorial.

更新:教程链接仍然有效,但实际code也可以在接下来的答案

Update: tutorial link still works, but actual code is also available in next answer.

这篇关于改变屏幕亮度以编程方式在机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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