系统定位丢失,或其他定位失效场景,sdk对外回调。支持外部输入定位信息更新导航
丢星回调:LocationLostListener
设置接口:BaiduNaviManagerFactory.getBaiduNaviManager().setLocLostListener(LocationLostListener)
BaiduNaviManagerFactory.getBaiduNaviManager().setLocLostListener(new IBaiduNaviManager.LocationLostListener() {@Overridepublic void locationLost(boolean b) {LogUtil.out("locationLost", "demo:" + b + " time:" + (System.currentTimeMillis() - mTime));mTime = System.currentTimeMillis();if (b) {handler.post(runnable);} else {handler.removeCallbacks(runnable);}}});long mTime = 0;private Handler handler = new Handler(Looper.getMainLooper());private Runnable runnable = new Runnable() {@Overridepublic void run() {System.out.println("更新定位");BaiduNaviManagerFactory.getBaiduNaviManager().setMyLocationData(new BNLocationData.Builder().latitude(location.getLatitude()).longitude(location.getLongitude()).accuracy(location.getAccuracy()).speed(location.getSpeed()).direction(location.getBearing()).altitude((int) location.getAltitude()).time(location.getTime()).build());// 再次调度handler.postDelayed(this, 1000);}};
收到丢星回调后,b=true 当前处在丢星状态。
通过BaiduNaviManagerFactory.getBaiduNaviManager().setMyLocationData设置当前位置。
正常使用应该在丢星状态定期更新当前定位,直到丢星状态消失
上一篇
下一篇
本篇文章对您是否有帮助?