简体   繁体   中英

How to keep data for a service after swiping off the application

Developing an android application where a background service continuously gets user location. It alarm user when he/she is about to reach destination specified by user.

To do so, I've to compare current location with the target location. The target location is acquired from another activity. Now when iam swiping off the application, the background service is running but is not able to compare with the cuurent location as the target destination coordinates is blank.

How to rectify this ?

The target location could be saved to a shared preference or a database or broadcast in an Intent from the Activity whenever it is changed. This will allow your Service to compare against it even if the Activity is no longer running.

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