简体   繁体   中英

How to update my location on activity when I am on other application

I have an app that the activity sends the user location to the server, how do I get the activity to keep sending the location to the server even when the application is in the background and the user is currently using another app?

For example I need that my application will work something like in WhatsApp "share my current location live" or Yango that even if the driver is on navigation and the app is in the background the user still gets the driver current location.

Basically, create a Service which is going to be reading the location and doing that. It get's a bit more complicated because Android added restrictions to background services and the rate at which apps in the background can get updates on new device location. This explains about services. The service will be started from the activity. The service will contain the code for fetching the locations

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