Getting Location Updates based on time interval or Displacement

旧街凉风 提交于 2019-12-01 20:09:34

Only for displacement

  mLocationRequest.setInterval(0);
  mLocationRequest.setFastestInterval(0);
  mLocationRequest.setSmallestDisplacement(SMALLEST_DISPLACEMENT);

Only for interval

 mLocationRequest.setInterval(POLLING_FREQ);
 mLocationRequest.setFastestInterval(FASTEST_UPDATE_FREQ);
 mLocationRequest.setSmallestDisplacement(0); // Not needed, already default value is 0

Normally interval and distance params are being calculated with AND. It means when you change your position at least SMALLEST_DISPLACEMENT meter AND at least POLLING_FREQ milliseconds have passed, then onLocationChanged() will be fired.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!