如何控制位置刷新inteval?

时间:2015-05-15 19:19:52

标签: android location refresh intervals

我只有一个问题:如何在此代码中控制.setInterval.setFastestInterval.setSmallestAmount,例如按下按钮?

 protected void createLocationRequest() {
        mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(INTERVAL);
        mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
        mLocationRequest.setSmallestDisplacement(10);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    }

我从OnCreate();

调用此方法

1 个答案:

答案 0 :(得分:0)

我不知道它对你有多大帮助。但也许其他人可能从这里得到帮助。 我写了一篇关于使用googleapiclient的位置服务的教程。你可以调查一下。 https://androidtutorialmagic.wordpress.com/2015/01/15/update-location-by-using-googleapiclient-in-android-tutorial/

mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(5000);

上面这两行可能对你有所帮助。