Search code examples
androidlocationfusedlocationproviderapi

Can I use fusedlocationproviderapi and force using GPS only?


I am using fusedlocationproviderapi in my Android app to transmit the users location. This works fine except sometimes the location jumps to a location in town and later shows that same location. I believe that the app switches from GPS to cell tower trialulation and in our area this does not work well.(MN) I use

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

in the manifest file and I would be fine with a way to ignore the faulty locations or detect those and not transmit those.

mLocationRequest = LocationRequest.create();
    mLocationRequest.setInterval(UpdateSeconds * 1000);
    mLocationRequest.setFastestInterval(UpdateSeconds * 1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

I use the above code which works pretty good when I get a GPS location.


Solution

  • If you're only interested in data coming from GPS, you can just use LocationManager with GPS_PROVIDER. I don't think of any benefit of using FusedLocationProviderApi if you're only interested in GPS.