1.此方法不需要集成百度的sdk 高德的sdk 节省了内存
2.只需要几行代码就能实现调用百度地图或者高德地图的sdk实现导航的功能
3.代码如下
private View.OnClickListener itemsOnClick = new View.OnClickListener(){ public void onClick(View v) { menuWindow.dismiss(); switch (v.getId()) { case R.id.btn_take_photo: try { //location是经纬度的值 title是到达的地方名字 Intent intent = Intent.getIntent("intent://map/marker?location="+findcar.getContent().get(p-1).getLat()+","+findcar.getContent().get(p-1).getLongX()+"&title="+findcar.getContent().get(p-1).getName()+"&content=百度奎科大厦&src=yourCompanyName|yourAppName#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end"); if(isInstallByread(FindCarActivity.this,"com.baidu.BaiduMap")){ startActivity(intent); //启动调用 }else{ Toast.makeText(FindCarActivity.this,"没有安装百度地图客户端",Toast.LENGTH_SHORT).show(); } } catch (URISyntaxException e) { e.printStackTrace(); } break; case R.id.btn_pick_photo: try { Intent intent = Intent.getIntent("androidamap://viewMap?sourceApplication=平治科技&poiname="+findcar.getContent().get(p-1).getName()+"&lat="+findcar.getContent().get(p-1).getLat()+"&lon="+findcar.getContent().get(p-1).getLongX() +"&dev=0"); if(isInstallByread(FindCarActivity.this,"com.autonavi.minimap")){ startActivity(intent); }else{ Toast.makeText(FindCarActivity.this,"没有安装高德地图客户端",Toast.LENGTH_SHORT).show(); } } catch (URISyntaxException e) { e.printStackTrace(); } break; default: break; } } };
/** * 判断是否安装了这个应用 * @param context * @param packagename * @return */ private Boolean isInstallByread(Context context,String packagename){ PackageInfo packageInfo; try { packageInfo =context.getPackageManager().getPackageInfo(packagename,0); } catch (PackageManager.NameNotFoundException e) { packageInfo = null; e.printStackTrace(); } if(packageInfo == null){ return false; }else{ return true; } }
转载于:https://my.oschina.net/handlermsg/blog/806403