Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update location every seconds with the help of workmanager

I am working on tracking app where i get the location update in background mode from gps. I have search on google i found that Android 12 - Foreground service launch restrictions. So you have use Work manager insted of foreground intentService.

And workManager minimum limit is 15 minutues for WorkManager Periodicity. Then how can i get location update every seconds in background mode.

Because workmanager request not run every seconds.

Thank you.

like image 416
Apavaiya Avatar asked Oct 14 '25 15:10

Apavaiya


1 Answers

When you are actively tracking the user you should use a Foreground Service. WorkManager is for cases where you care for the Work to finish, but the priority will be to save the battery.

I can assure you that WorkManager is the wrong API for you.

Why do you need to start the service from the background? What is your exact use case?

Check here:

https://developer.android.com/guide/background#replacing-foregound

Some use cases for using foreground services directly are as follows:

  • Media playback
  • Activity tracking
  • Location sharing
  • Voice or video calls
like image 123
Yavor Mitev Avatar answered Oct 17 '25 03:10

Yavor Mitev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!