通过是否发起活动线程继续运行,一旦设备进入睡眠状态? [英] Does a Thread launched by Activity continue running once the device goes to sleep?

查看:165
本文介绍了通过是否发起活动线程继续运行,一旦设备进入睡眠状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是有点类似<一个href=\"http://stackoverflow.com/questions/5345344/app-seems-to-stop-working-when-the-screen-goes-to-sleep\">App似乎停止工作时,屏幕进入休眠状态但他们讨论的AsyncTask的,而在我的情况下,它是一个普通的线程。

This is somewhat similar to App seems to stop working when the screen goes to sleep however they discuss an AsyncTask while in my situation it is a plain Thread.

所以我们说一个活动启动一个线程,然后手机进入睡眠状态,并线程继续执行?

So let's say an activity starts a Thread, and then the phone goes to sleep, does the thread continue execution?

推荐答案

除非你有一个的激活锁定。 (它不会继续,如果你的活动转到后台运行,但可能会在前台活动需要更多的资源任何时候被杀死。)

Not unless you have a wakelock. (It does continue to run if your activity goes to the background, but might be killed at any time the foreground activity requires more resources.)

这篇关于通过是否发起活动线程继续运行,一旦设备进入睡眠状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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