I have tried job scheduler and work manager but it does not work in doze mode and not at regular period. I have used normal service which is not working on some Chinese custom rom phone specially oppo and vivo.

I have used the Alarm Manager to start service but it also not working any type of solution not working on this phone.

1

There are 1 best solutions below

2
On

If you really want to have it working on all devices, I suggest you this approach:

  1. Set up Firebase messaging
  2. Subscribe all devices to specific topic e.g. "UPDATE_LOCATION"
  3. Extend FirebaseMessagingService and implement onMessageReceive()
  4. If your data message contains instruction to update location, call the method to update location from onMessageReceive()
  5. Trigger recurring messages to "UPDATE_LOCATION" topic from Firebase (CRON job or scheduled tasks)

It's a little more work that methods you have already tried, but it works on all phones and also after device restart and system update.

Additional plus is that you have control over the location updater from your backend (not per device which relies on app update).