如何prevent Android设备的活动的执行过程中关闭屏幕?过程中、屏幕、设备、prevent

由网友(坟场蹦迪)分享简介:我有一个活动,通常需要一些时间来观看屏幕,不与其进行交互。I have an Activity that usually needs some time to watch the screen without interacting with it.问题是,屏幕将自动关闭,就像Almos酒店的其他应用程序。我想p...

我有一个活动,通常需要一些时间来观看屏幕,不与其进行交互。

I have an Activity that usually needs some time to watch the screen without interacting with it.

问题是,屏幕将自动关闭,就像Almos酒店的其他应用程序。 我想prevent的自动关闭我的活动,像海豚高清呢(如果你在设置菜单中进行配置)。

The problem is that the screen turns off, just like with almos any other app. I want to prevent that automatic turn off for my Activity, like Dolphin HD does (if you configure it from the settings menu).

我想让用户关闭屏幕pressing平时块按钮,但prevent设备的自动闭塞,而​​在我的活动

I want to let the user to turn off the screen pressing the usual block button, but prevent the automatic block of the device while in my Activity.

我怎样才能做到这一点?

How can I achieve this?

感谢名单。

推荐答案

添加安卓keepScreenOn =真正的来为这次活动你的布局XML资源的一些小部件。只要该部件是在屏幕上可见,屏幕也不会自动关闭。

Add android:keepScreenOn="true" to some widget in your layout XML resource for this activity. So long as that widget is visible on the screen, the screen will not turn off automatically.

编辑:

A WakeLock 建议的那样,其他的答案,在技术上将工作。但你必须手动释放 WakeLock (如果你陷入困境,高达,屏幕上会停留在很长一段时间)。而且,由于你的可以的搞砸了,你需要的 WAKE_LOCK 许可。使用 keepScreenOn 避免这一切。

A WakeLock, as suggested by other answers, technically will work. But then you have to manually release the WakeLock (if you mess that up, the screen will stay on a long time). And, since you could mess it up, you need the WAKE_LOCK permission. Using keepScreenOn avoids all of that.

阅读全文

相关推荐

最新文章