'Some time Android Fused location client return wrong location (I am in India but it returns location for US Colorado)
Below is the code used for getting the location
private fun requestLocation() {
Utils.print("LocationUpdateService","request location per minute")
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return
}
if (locationRequest != null)
mFusedLocationClient?.requestLocationUpdates(
locationRequest!!,
locationCallback,
Looper.myLooper()!!
)
}
locationRequest = LocationRequest.create()
locationRequest?.apply {
fastestInterval = 1000 * (AppPreference.getLocationInterval(applicationContext)-AppPreference.getLocationInterval(applicationContext)/10)
interval = 1000 * AppPreference.getLocationInterval(applicationContext)
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
}
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(applicationContext)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
