0

Hey guys I'm creating an app like uber almost and the driver needs to update his location every seconds without stopping I started service on a new process gets the fused location updates

This way

fusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());

So when the driver on the UI it always perfect when he gets out the UI and go background it stops updating at all after seconds but the problem is the drivers are always outside the app even tho I have floating is there anyway else to keep the UI somehow there but not there? like notifications? does it work or maybe timer? keep the app on I have no idea what could help in this situation anything guys?

The Service in the manifest is

<service
        android:name=".Services.LocationService"
        android:exported="true"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:enabled="true"
        android:icon="@drawable/logo"
        android:description="@string/location_access_description"
        android:foregroundServiceType="location"
        android:process=":locationService"
        />
BKSO
  • 23
  • 1
  • 5
  • Go for [WorkManager](https://codelabs.developers.google.com/codelabs/android-workmanager-java/#3) – Sniffer Oct 12 '20 at 04:56
  • Is this gonna give me locations even in the background? every 2 seconds and without heavy load? if yes that would be soo good actually – BKSO Oct 12 '20 at 05:02
  • 1
    https://stackoverflow.com/a/64275274/9102978 Check this if it is helpful – Rudrik Patel Oct 12 '20 at 06:06
  • 1
    I think you are using a foreground service. What is your target SDK? – Eyosiyas Oct 12 '20 at 07:02
  • 1
    @BKSO yes WorkManager can give you location coordinates in the background without any limitations and most important it works above API 14 also. Where Service kill in Android 10. Check this [doc](https://developer.android.com/topic/libraries/architecture/workmanager/?gclid=CjwKCAjw_Y_8BRBiEiwA5MCBJvhKOEGK0hRYqcDH6fL0W-R_BwIBMUfizg5TOzyu4B0NV89z1xy5WhoCo10QAvD_BwE&gclsrc=aw.ds) – Sniffer Oct 12 '20 at 11:38

0 Answers0