进入睡眠模式,当应用程序正在运行prevent移动应用程序、睡眠、正在运行、模式

由网友(滚啊老子最酷)分享简介:我想prevent的Andr​​oid手机进入睡眠模式时,我的线程发送HTTP请求。作为同时线程正在执行HTTP调用手机发生了什么事进入睡眠模式,当用户唤醒了电话线永远不会完成。I want to prevent Android Mobile from going into sleep mode when my th...

我想prevent的Andr​​oid手机进入睡眠模式时,我的线程发送HTTP请求。作为同时线程正在执行HTTP调用手机发生了什么事进入睡眠模式,当用户唤醒了电话线永远不会完成。

I want to prevent Android Mobile from going into sleep mode when my threads are sending HTTP request. as what happened while threads are doing HTTP calls mobiles goes to sleep mode and when user wakes up the phone threads never complete.

用户必须重新启动应用程序。该怎么办?请大家帮忙

User has to restart the app. what to do? please help

推荐答案

您需要 WakeLock 。有各种不同的唤醒锁,所以一定要选择最积极的一个能满足您的需求。尤其是,它听起来像你需要一个局部唤醒锁。

You need a WakeLock. There are different kinds of wake locks so be sure to select the least aggressive one that meets your needs. In particular it sounds like you need a Partial Wake Lock.

部分唤醒锁 - 唤醒锁,保证了CPU运行。屏幕可能不能上。

Partial Wake Lock - Wake lock that ensures that the CPU is running. The screen might not be on.

此外,还要确保你的权限 android.permission.WAKE_LOCK 添加到您的清单。最后是双务必Release你的锁,当你做。

Also, make sure you add the permission android.permission.WAKE_LOCK to your manifest. And finally be double sure to Release your lock when you are done.

阅读全文

相关推荐

最新文章