setFastestInterval(long milis) not working

时间秒杀一切 提交于 2019-12-14 02:38:37

问题


I want to slow the update rates as soon as I got a location precise enough for my needs:

    @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);

The method is called but I still got updates every 3 seconds and a half. I have a ViewPager with a maps 2.0 fragment but I did mapFragment.getMap().setMyLocationEnabled(false);

How do I slow updates? Why FastestInterval is not working?


EDIT: I test my slow updates on the dummy application provided by Google docs and it works ok. I added a LogCat getFastestInterval and getInterval and I got the 15 and 30 seconds I was expecting in the test context. BUT the update rate is still freaking too high.


回答1:


I got this !

The mistake is mine and can be resume in this

DO NOT CALL AGAIN mLocationClient.requestUpdates(mLocationRequest,this);

Also, remember that the default fastest interval is your normal interval/6 .



来源:https://stackoverflow.com/questions/18914316/setfastestintervallong-milis-not-working

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