注:订阅上车提醒后会根据订阅参数中的索引站点, 通过realtimebusnotifylistener返回实时公交是否到站信息, sdk内部未做提醒之后取消提醒的逻辑,最近的车辆驶过之后会继续查询下一辆公交车辆的信息并发出提醒, 如需取消订阅上车提醒需调用unregistergetonbussubscription接口。
realtimebusnotifylistener realtimebusnotifylistener =newrealtimebusnotifylistener(){@overridepublicvoidgetonbusnotify(realtimebusstatus info){// 上车提醒状态回调}@overridepublicvoidgetoffbusnotify(realtimebusstatus info){// 下车提醒状态回调}@overridepublicvoiderrormessage(searchresult.errorno subscriberesult){// 订阅结果错误信息返回}};
subscriber subscriber =newsubscriber();subscriber.setlocation(latlng);// 设置当前位置boolean res =realtimebusmanager.getinstance().registergetonbussubscription(subscriber,// 订阅者位置getonbusindex,// 站台索引buslineuid,// 线路uid131,// 城市idrealtimebusnotifylistener);// 监听数据回调if(res){toast.maketext(rtbuslineactivity.this,"开启上车提醒成功",toast.length_short).show();}else{toast.maketext(rtbuslineactivity.this,"开启上车提醒失败,请检测相关订阅参数并重新设置",toast.length_short).show();}
注:下车提醒在分别提醒还有一站和还剩一分钟,车辆到站之后sdk内部会取消下车提醒的订阅
subscriber subscriber =newsubscriber();subscriber.setlocation(latlng);// 设置当前位置boolean res =realtimebusmanager.getinstance().registergetoffbussubscription(subscriber,getoffbusindex,// 下车站台索引buslineuid,// 线路uid131,// 城市idrealtimebusnotifylistener);if(res){toast.maketext(rtbuslineactivity.this,"开启下车提醒成功",toast.length_short).show();}else{toast.maketext(rtbuslineactivity.this,"开启下车提醒失败,请检查参数并重新开启",toast.length_short).show();}
realtimebusmanager.getinstance().unregistergetonbussubscription();
realtimebusmanager.getinstance().unregistergetoffbussubscription();
上一篇
下一篇
本篇文章对您是否有帮助?