Fused Location Provider setsmallestDisplacement doesn't work in Android

前端 未结 2 433
温柔的废话
温柔的废话 2020-12-08 05:17

Hi I have implemented Fused Location provider Api for getting location updates in a service. I was able to get the onlocationchanged event fired according to the interval se

2条回答
  •  时光取名叫无心
    2020-12-08 05:29

    It may happen that you are getting different lat-long in onLocationChanged method which describes more displacement than 10. So kindly checkout the lat-long which you are getting and measure the distance once manually to cross-verify the things.

    Apart from above, one more possible reason is matter of priority, If above case seems fine then try like following:

     mlocationrequest = LocationRequest.create();
    mlocationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mlocationrequest.setSmallestDisplacement(10);
    mlocationrequest.setInterval(60000); // Update location every 1 minute
    mlocationrequest.setFastestInterval(10000);
    

提交回复
热议问题