【问题标题】:setFastestInterval(long milis) not workingsetFastestInterval(long milis) 不工作
【发布时间】:2013-09-20 10:17:50
【问题描述】:

我想在获得足够精确的位置以满足我的需求后立即降低更新速度:

    @Override
public void slowUpdateRate() {
    /*
     * Set the update interval 
     */
    Dbg.v(TAG,"****************************");
    Dbg.e(TAG, "-- SLOW update rate");
    Dbg.v(TAG,"****************************");
    stopUpdates();
    mLocationRequest.setInterval(1500000);
    mLocationRequest.setFastestInterval(150000);
    mLocationClient.requestLocationUpdates(mLocationRequest, this);

该方法已被调用,但我仍然每 3 秒半更新一次。我有一个带有 maps 2.0 片段的 ViewPager 但我做了mapFragment.getMap().setMyLocationEnabled(false);

如何减慢更新速度?为什么 FastestInterval 不起作用?


编辑:我在谷歌文档提供的虚拟应用程序上测试了我的缓慢更新,它工作正常。我添加了一个 LogCat getFastestInterval 和 getInterval,我得到了我在测试环境中所期望的 15 秒和 30 秒。但是更新率仍然太高了。

【问题讨论】:

    标签: android geolocation android-maps-v2 location-client


    【解决方案1】:

    我明白了!

    错误是我的,可以在此恢复

    不要再次致电mLocationClient.requestUpdates(mLocationRequest,this);

    另外,请记住默认的最快间隔是您的正常间隔/6。

    【讨论】:

    • LocationClient 已弃用。查看当前选项的答案:LocationManager or Location Service API
    • 感谢您的评论。它在一年前被弃用了吗?现在我正在使用 LocationManager。请注意,您必须考虑到新的 FusionLocation api 是 Google 服务的一部分,可能不适用于某些项目。
    猜你喜欢
    • 2014-11-24
    • 1970-01-01
    • 1970-01-01
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多