-1

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.

SkunkSpinner
  • 11,429
  • 7
  • 40
  • 53
  • 1
    Please place here some code of your. – Mukta Ghosh Oct 30 '19 at 11:51
  • public class LatLngService extends Service implements com.google.android.gms.location.LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { @SuppressWarnings("deprecation") @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); if (thirtysecHandler == null) { thirtysecHandler = new Handler(); thirtysecHandler.postDelayed(thirtySec, 30000*1); } } – Pravin Rai Oct 31 '19 at 10:59

1 Answers1

1

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).

Simon
  • 1,657
  • 11
  • 16
  • Sir; i have to send latitude and longitude from android app to server at regular interval of time of 3 Minute to track user on web panel any suggession. I have written service class to send data to server its working fine on stock android but not on MIUI, funtouchOS, coloros custoom rom it blocking background service – Pravin Rai Oct 31 '19 at 06:27
  • Exactly. It works on some devices, but not all. To have 100% success rate, I'd suggest you the approach above. – Simon Nov 01 '19 at 07:18