简体   繁体   English

设备处于睡眠状态(屏幕关闭)时,Android获取GPS坐标更新

[英]Android getting GPS coordinate updates while device is in sleep (Screen is turned off)

I have a problem. 我有个问题。 I want to get GPS coordinate updates while the device is in sleep mode (The user turned the screen off). 我想在设备处于睡眠模式(用户关闭屏幕)时获取GPS坐标更新。

I'm currently using a service to get the GPS coordinates in a background task, but this service stops after a moment when the device is in sleep mode. 我当前正在使用一项服务来在后台任务中获取GPS坐标,但是当设备处于睡眠模式后此服务会停止。 How can I achieve to get continously the current GPS coordinates, as long as the service should run? 只要服务可以运行,我如何才能连续获取当前的GPS坐标?

Why I need that? 为什么我需要那? Its to check when the user reaches a certain place, to get a notification. 它检查用户何时到达某个地方,以获得通知。

A service must be able to do it. 服务必须能够做到这一点。 Try the IntentService class instead of the Service class to create your own service. 尝试使用IntentService类而不是Service类来创建您自己的服务。

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

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