Android 设备睡眠问题
当我设置设备不休眠的选项时,我遇到了一个小问题。我正在连接到网络服务器并下载数据,当我这样做时,我需要设备保持唤醒状态。我以这种方式使用它:
1.在我的 Synchronization 类中,当我开始连接到 Web 服务器时,我设置了这个:
PowerManager powerMan = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = powerMan.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
wl.acquire();
并在此活动中设置了 onDestroy()
方法:
wl.release();
但似乎此后,即使我关闭应用程序,设备也不会休眠。我做错了什么吗?提前致谢!
I have a little issue when I set option for device not sleeping. I'm connecting to web server and downloading data and when I'm doing this I need the device stay awake. I'm using this in this way :
1.In my Synchronization class when I start a connection to a web server I set this :
PowerManager powerMan = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = powerMan.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
wl.acquire();
and onDestroy()
method in this activity I set :
wl.release();
But it seems that after this the device is not sleeping even if I close my application. Is there something that I'm doing wrong. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用此选项而不是
WakeLock Manager
:这将使您的屏幕保持打开状态,您可以通过执行他的操作来删除该选项:
这应该会有所帮助。
Try to use this instead of
WakeLock Manager
:this will keep your screen on and you can remove that option by doing his :
This should help.