我怎样才能改变LocationRequest间隔 [英] How can I change the interval of LocationRequest

查看:452
本文介绍了我怎样才能改变LocationRequest间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把我的应用程序,以获得每5秒位置通知。

I set my application to get location notification every 5 seconds.

    mLocationRequest = LocationRequest.create();
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setInterval(5000);
    mLocationRequest.setFastestInterval(5000/6);
    myLocationReq.requestLocationUpdates(mLocationRequest

让 - 每隔5秒,onLocationChanged被调用。 这是工作的罚款。

so - every 5 seconds, onLocationChanged is being called. This is working fine.

现在我想改变的时间间隔为1秒,而无需调用

Now I want to change the interval to be 1 second, without calling

     requestLocationUpdates

如何才能做到这一点?

How can this be done?

推荐答案

希望这个答案还不算晚,但只需创建一个LocationRequest对象,与所需的setInterval值。然后,只需拨打requestLocationUpdates吧。

Hope this answer isn't too late, but simply create a LocationRequest object, with the desired setInterval value. And then just call requestLocationUpdates with it.

我用这与标签,其中1片必须得到位置更新比别人快。所以,我只是改变了onResume和方法的onPause的时间间隔。

I used this with tabs where 1 tab had to get location updates faster than the others. So I just changed the interval in the onResume and onPause methods.

这篇关于我怎样才能改变LocationRequest间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆