繁体   English   中英

如何在Android中通过常规位置更新运行服务

[英]How can I run a service with regular location updates in android

我在服务中使用LocationListener获取常规位置更新。 当我关闭该进程时,该服务不会向我提供任何更新。 我能做什么?

您充当START_STICKY。

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    // initialize location
    initLocation();
    Log.e("", "onStartCommand");
    return START_STICKY;
}

它会在杀死后在后台运行。如果有任何位置更新,您可以获取更新。

暂无
暂无

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

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