简体   繁体   中英

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

I'm using LocationListener in my service to get regular location updates. When I close the process, the service does not give any updates to me. What can I do?

you service as a START_STICKY.

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

It will run in background after kill..and if there is any update of location you can get update.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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