Android 2.2的:在一天的某些时段屏幕转向由code [英] Android 2.2: Turning of screen under certain times of the day by code

查看:81
本文介绍了Android 2.2的:在一天的某些时段屏幕转向由code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有什么办法可以关闭屏幕在Android设备上,例如19.00-22.00每一天。我在kiosk模式下运行的一些药片,我要的屏幕关闭时,没有人使用它们,商店被关闭。

I would like to know if there is any way to turn off the screen on an android device on for example 19.00-22.00 every day. I have some tablets running in kiosk mode, and i want the screens to turn off when no one is using them and the store is closed.

感谢

推荐答案

屏幕会自动关闭,如果你有在设备设置中设置正确。

Screens will turn off automatically, if you have that set up properly in the device settings.

您可以使用 AlarmManager 激活锁定安排在工作时间,以保持设备屏幕清醒。有 AlarmManager 启动所获取激活锁定并等待,直到截止时间的服务。您将需要使用 startForeground()从杀死你的服务的服务为prevent Android系统。

You can use AlarmManager and a WakeLock to arrange to keep the device screen awake during business hours. Have the AlarmManager start up a service that acquires the WakeLock and waits until closing time. You will need to use startForeground() in the service to prevent Android from killing off your service.

在现实世界中,这种实现将吮吸,因为它迫使你保持一个服务运行所有的时间 - 如果你让服务关闭,你失去了激活锁定,从来没有发布(),所以画面会永远关闭。所以,这样的事情亭外面,我不推荐这种技术。

In the real world, this implementation would suck, as it forces you to keep a service running all the time -- if you let the service shut down, you lose the WakeLock and can never release() it, so the screen will never shut off. So, outside of this sort of kiosk thing, I do not recommend this technique.

这篇关于Android 2.2的:在一天的某些时段屏幕转向由code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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