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

问题描述

这是有点类似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.)

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

08-20 06:22
查看更多