编程设定屏幕关闭的机器人 [英] programmatically set screen to off in android

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

问题描述

我可以编程设定屏幕关闭在Android中,如果不活动1分钟内自动完成的。

can I programmatically set screen to off in android if is not done automatically after 1 minute of inactivity.

这是可以做到的编程方式在android的?

is this possible to do programmatically in android?

我发现这个线程: <一href="http://stackoverflow.com/questions/9561320/android-how-to-turn-screen-on-and-off-programmatically">Android:如何打开屏幕和关闭编程?

<一个href="http://stackoverflow.com/questions/13416563/turning-screen-on-and-off-programmatically-not-working-on-some-devices">Turning屏幕打开和关闭编程不工作的一些设备

但没有定时器1分钟。

推荐答案

是的,在这种情况下,最好使用该方法以编程方式设置屏幕超时代替。

Yes, the method best used in this case is to programmatically set screen timeout instead.

Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);

1000以毫秒为单位,这意味着1秒,你可以根据需要任意值替换它。

1000 is in milliseconds which means 1 second, you can replace it with any value as desired.

所需的权限:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />

这篇关于编程设定屏幕关闭的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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