我如何使用Android4.0的不断Full_Wake_Lock? [英] How do i use the constant Full_Wake_Lock in android4.0?

查看:261
本文介绍了我如何使用Android4.0的不断Full_Wake_Lock?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着去创建一个程序来保持键盘的背光如果屏幕上。林很新到Android,但我一直在为6个月的Java编程。林不知道如何使用常量Full_Wake_Lock保持KB lgiht上。

Im trying to create a program to keep the keyboard backlight on if the screen is on. Im very new to android but i have been programming java for 6months. Im not sure how to use the constant Full_Wake_Lock to keep the kb lgiht on.

推荐答案

您将需要开始的 服务 。结果
然后,你就必须获得的onCreate内之后锁定,那么你会释放激活锁定了的onDestroy。也就是说,如果你正在试图抓住从背景中唤醒锁。

You would need to start a Service.
Then you would have to acquire the wake lock within the onCreate, then in the onDestroy you would release the WakeLock. That is if you are trying to hold the wake lock from the background.

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
wl.acquire();

这是获得它,然后将它释放

that is to gain it, and then to release it:

wl.release();

当然,你会想申报 WL 类体中的任何方法之外。

And of course, you would want to declare wl within the class body outside of any methods.

这篇关于我如何使用Android4.0的不断Full_Wake_Lock?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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