【问题标题】:i want location after certain time in android not when i move from one place to another我想在 android 中的某个时间后定位,而不是当我从一个地方移动到另一个地方时
【发布时间】:2011-05-12 19:14:29
【问题描述】:

我想在特定时间后获取位置,因此我可以在方法 requestslocationupdates 中定义最短时间。例如,我写了 60 秒,所以我想在 60 秒后得到位置。我明白了。但是当我从一个地方搬到另一个地方时,问题就出现了,所以也得到了定位,但我不想要这个。我只想要一段时间后的位置..

我的代码在这里。

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    locationListener = new GPSLocationListener();
    Criteria criteria = new Criteria();
    //criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    //criteria.setAccuracy(Criteria.ACCURACY_FINE);
    provider = locationManager.getBestProvider(criteria, false);

    locationManager.requestLocationUpdates(
            provider, 
        0, 
        0, 
        locationListener);

【问题讨论】:

    标签: android


    【解决方案1】:
    locationManager.requestLocationUpdates(provider,60000,0,locationListener);
    

    【讨论】:

    • 我做到了,但有时当我从一个地方移动到另一个地方时,我也会得到位置..我想要某个特定时间的位置..
    • 那么你必须使用TimerTask
    • 如果我不能通过上述方法的最短时间,那么先告诉我?我给你我的代码链接给你我已经为此实现了计时器?..................stackoverflow.com/questions/5976282/…
    • "minTime - 通知的最小时间间隔,以毫秒为单位。此字段仅用作节省电量的提示,位置更新之间的实际时间可能大于或小于此值。"不要相信 requestlocationupdates 中设置的时间是准确的。我听说在某些情况下它仍然会尽可能频繁地报告。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 2016-03-05
    相关资源
    最近更新 更多