简体   繁体   中英

Get Location updates in background without running Service in Android

I want to fetch the current Location of the user in background. I know how it can be done using Service in Android. But I would like to know is there any possibilities to get user Location without running service. Like using BroadcastReceiver or anything? I'm just trying to avoid running Service to fetch Location .

For Example I referred this link . But I couldn't follow how to do like this.

Any help will be appreciated. Correct me in case I'm asking anything wrong.

EDIT: Oh, I think in the above link he is using Service to get the Location. So I think it's not possible to get location in background without running a Service. Still suggestions are welcomed.

You Should Implement a BroadcastReceiver that receives alarm every 2 hours. That alarm is Set by Your Activity.

When the alarm is triggered by your System, Broadcast Receiver receives it, Executes Your Process in BroadCastReceiver.

This is what i can think of.

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