简体   繁体   English

Android 服务在后台运行而不休眠?

[英]Android service running in background without sleep?

i'm doing a location grabbing service for my phone.我正在为我的手机提供位置抓取服务。 The main activity sets some timing like 10min interval which results in the servicing running polling both gps and network location for the first 1 min then post the result in http then rest for the 9mins.主要活动设置一些时间间隔,例如 10 分钟间隔,这会导致服务运行轮询 gps 和网络位置前 1 分钟,然后将结果发布到 http 然后 Z65E8800B5C6800AAD896F888B2A62 的 9 分钟。 The questions is, does the service get destroyed in deep sleep?问题是,服务会在深度睡眠中被破坏吗? if thats the case i'll have to use alarm manager for it?如果是这样,我将不得不使用警报管理器吗?

It is not destroyed, it is sleeping.它没有被摧毁,它正在沉睡。 When you wake your phone up it must continue working and getting location updates.当您唤醒手机时,它必须继续工作并获取位置更新。

You need to use AlaramManager or WakeLock您需要使用AlaramManagerWakeLock

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM