1

We are using location updates in constant intervals to provide our service using Foreground service. With Android 9 the service completely stops until user unlocks the screen. It is working fine in Android O and pre O devices. I turned to internet and tried to use all the work around available. But nothing seems to work. Any one is facing this issue ? Is there any solution ?

According to the docs , Foreground services with notifications are exempted from blocking. I have tried to use wake up lock and Alarm manager . Nothing worked so far. What am I missing ? There is no clear documentation nor Stack over flow answers this .

rana
  • 1,824
  • 3
  • 21
  • 36

1 Answers1

0

In 26 and above You have to mention the foreground Service type as Location in the AndroidManifest

           <service
            android:name="LocationUpdatesService"
            android:enabled="true"
            android:exported="true"
            android:foregroundServiceType="location" />

And You have to call ContextCompat.startForegroundService(getApplicationContext(), intent); instead of just calling startService() as in Pre-O OS versions.

rana
  • 1,824
  • 3
  • 21
  • 36