• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Fetch User Location when the App is closed and Handle doze mode.

I have a usecase when I need to fetch user location for every 5 min say (this is configurable but not less than 5 min). I have tried the following:

1) Alarm manager and setting it to Periodic , thereby raising a broadcast from which triggering a Foreground service and holding a partial wake lock to fetch location and send to server.

2) next Approach was using the work manager API to do all this process. but this deferred the task a lot and in MI mobile the task totally terminated when the app is removed from the App tray.

3) Used oneshot alarms by setting the time manually and triggering next alarm in the broadcast. It also got deferred.

What should i do to solve this issue. Tried even with Removing Battery Optimization.

 
Back
Top Bottom