@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initView();
}
private void initView() {
speedBar = findViewById(R.id.navi_speed_style);
roadName = findViewById(R.id.navi_road_name);
limitSpeed = findViewById(R.id.navi_limit_speed);
speed = findViewById(R.id.navi_speed);
speedBar.setVisibility(View.VISIBLE);
if (tencentCarNaviManager != null) {
//添加导航协议
tencentCarNaviManager.addNaviView(speedView);
}
}
private INaviView speedView = new INaviView() {
@Override
public void onShowGuidedLaneInfo(GuidedLaneInfo guidedLaneInfo) {
}
@Override
public void onRouteDidChange(RouteData routeData, ArrayList<TrafficItem> arrayList) {
}
@Override
public void onRouteDidChange(RouteData routeData, ArrayList<TrafficItem> arrayList, RouteChangedReason routeChangedReason) {
}
@Override
public void onDeleteBackupRoutes(ArrayList<String> arrayList) {
}
@Override
public void onAddBackupRoutes(ArrayList<RouteData> arrayList) {
}
@Override
public void onUpdateTraffic(RouteTrafficStatus routeTrafficStatus) {
}
@Override
public void onUpdateBackupRoutesTraffic(ArrayList<RouteTrafficStatus> arrayList) {
}
@Override
public void onRouteRecommend(RecommendRouteInfo recommendRouteInfo) {
}
@Override
public void onGpsRssiChanged(int i) {
}
@Override
public void onUpdateNavigationData(NavigationData navigationData) {
roadName.setText(navigationData.getCurrentRoadName());
speed.setText(navigationData.getCurrentSpeed() + "");
limitSpeed.setText(navigationData.getLimitSpeed() + "");
}
@Override
public void onShowEnlargedIntersection(Bitmap bitmap) {
}
@Override
public void onHideEnlargedIntersection() {
}
@Override
public void onShowGuidedLane(Bitmap bitmap) {
}
@Override
public void onHideGuidedLane() {
}
@Override
public void onUpdateTraffic(String s, int i, int i1
, ArrayList<LatLng> arrayList
, ArrayList<TrafficItem> arrayList1, boolean b) {
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
daynightMode = findViewById(R.id.navi_daynight_mode);
carNaviView.setDayNightModeChangeCallback(dayNightModeChangeCallback);
daynightMode.setVisibility(View.VISIBLE);
daynightMode.setOnCheckedChangeListener((group, id)->{
switch (id){
case (R.id.auto_mode):
carNaviView.setDayNightMode(DayNightMode.AUTO_MODE);
break;
case (R.id.day_mode):
carNaviView.setDayNightMode(DayNightMode.DAY_MODE);
break;
case (R.id.night_mode):
carNaviView.setDayNightMode(DayNightMode.NIGHT_MODE);
break;
}
});
}
/**
* 可以设置导航日夜模式状态回调,在日夜状态变化时通知用户
* /*|||铁塔换电https://29381f30e924b899961487a07c061d950a7bf67a>>换电https:// 4e4a20a4462309f7f349516d620e0cf3d7cad6af9>>茉莉花https://4e4a20a4462309f7f349516d620e0cf3d7cad6af|||*/
————————————————
版权声明:本文为CSDN博主「a518618718」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/a518618718/article/details/130842407
*/
private DayNightModeChangeCallback dayNightModeChangeCallback = new DayNightModeChangeCallback() {
@Override
public void onDayNightModeChanged(boolean b) {
if(b){
Log.e("DayNightMode", "night");
Toast.makeText(SetDayNightModeActivity.this, "夜间", Toast.LENGTH_SHORT).show();
}else {
Log.e("DayNightMode", "day");
Toast.makeText(SetDayNightModeActivity.this, "日间", Toast.LENGTH_SHORT).show();
}
}
};
新李点吃-腾讯地图导航协议
最新推荐文章于 2024-11-02 10:50:29 发布
该代码段展示了在一个Android活动中如何初始化导航界面元素,如速度条、道路名称和限速显示。同时,它实现了INaviView接口来处理导航事件,并创建了一个DayNightModeChangeCallback实例来监听和响应日间/夜间模式的变化,向用户展示相应的提示。
摘要由CSDN通过智能技术生成