Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

android - Doze mode - do foreground services continue to run?

im so confused reading this and trying to figure out if foreground services will run when the device goes into deep doze mode. Could someone clarify. I want to know on marshmallow and upwards if foreground services can continue to run. I always thought ALL THREADs are suspended even foreground services when device sleeps.

I see the doze mode restrictions but nothing about foreground services. im so confused if my services outlives doze mode security settings.

From what i can tell in the doze mode restrictions just network calls are stopped. But lets say i was doing some long running main thread work, it means it can continue to run right ? even in doze mode ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Foreground services are not killed in doze mode and it's a great workaround to override the doze mode. Killing the foreground service is highly depending on Mobile OS. Like Huawei, it kills the foreground services after a slack of time and you will not be able to determine the period. Some other phones kill the oldest foreground service if it detects unexpected battery consumption. last year, I spent around 6 months observing phones behavior in killing the foreground services when doze mode is activated or not. and I tried more than one solution to override the doze mode in detecting location every 10 seconds and the best one is the foreground service. So you will face unexpected behavior on some phones but it is the best solution for doze and standby mode. You can see this article and you can also look at this tutorial


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...