android自APP打开高德,百度,腾讯地图APP调用(整理非原创)

一:高德

高德:com.autonavi.minimap

高德接口说明:http://lbs.amap.com/api/amap-mobile/guide/android/route

你可以验证存不存在,不存在则可提示相关信息;

 if (isInstallByread("com.autonavi.minimap")) {
                     
      //跳转处理
    }else {
      Toast.makeText(MainActivity.this,"未安装该应用",Toast.LENGTH_LONG).show();
    }   
 
 private boolean isInstallByread(String packageName) {
        return new File("/data/data/" + packageName).exists();
  }

高德文字规划路线

 //单独导航
 
   Intent intent = new Intent("android.intent.action.VIEW",
   android.net.Uri.parse("amapuri://route/plan/?dlat=39.98848272&dlon=116.47560823&dev=0&t=0"));
   //"androidamap://navi?sourceApplication=appname&poiname=fangheng&lat=26.57&lon=106.71&dev=1&style=2"
   // amapuri://route/plan/?sname=A&did=BGVIS2&dlat=39.98848272&dlon=116.47560823&dname=B&dev=0&t=0
   intent.setPackage("com.autonavi.minimap");
   //context.startActivity(intent);
 
   //反地理编码
   /*Intent inten1 = new Intent("android.intent.action.VIEW"
     , android.net.Uri.parse("androidamap://viewReGeo?sourceApplication=softname&lat=26.57&lon=106.71&dev=1"));
    inten1.setPackage("com.autonavi.minimap");// pkg=com.autonavi.minimap
    inten1.addCategory("android.intent.category.DEFAULT");
    context.startActivity(inten1);*/
 
  //地理编码
    Intent inten2 = new Intent("android.intent.action.VIEW",                  
    android.net.Uri.parse("androidamap://keywordNavi?sourceApplication=softname&keyword=贵州省贵阳市&style=2"));
    inten2.setPackage("com.autonavi.minimap");
    inten2.addCategory("android.intent.category.DEFAULT");
    startActivity(inten2);

二:百度

百度:com.autonavi.minimap

百度接口说明:http://lbsyun.baidu.com/index.php?title=uri/api/android

  // Intent intent = Intent.getIntent("intent://map/direction?origin=latlng:26.58&destination=latlng:26.57&mode=transit&src=某某公司#Intent;" + "scheme=bdapp;package=com.baidu.BaiduMap;end");
 
  //Intent intent = Intent.getIntent("intent://map/direction?origin=" + loc1 + "&destination=" + loc2 + "&mode=transit&src=某某公司#Intent;" + "scheme=bdapp;package=com.baidu.BaiduMap;end");
      //Intent intent = Intent.getIntent("intent://map/direction?destination=latlng:26.57+106.71&mode=transit&src=某某公司#Intent;" + "scheme=bdapp;package=com.baidu.BaiduMap;end");
      //起点  此处不传值默认选择当前位置
      Intent intent = Intent.getIntent("intent://map/direction?destination=贵阳市粮食局&mode=driving&src=XX科技有限公司#Intent;" + "scheme=bdapp;package=com.baidu.BaiduMap;end");

 
          /*  Intent intent =new  Intent();
            intent.setData(Uri.parse("baidumap://map/direction?destination=26.57,106.71&mode=driving"));*/
            startActivity(intent);

三:腾讯

腾讯:com.tencent.map

腾讯接口说明:https://lbs.qq.com/uri_v1/guide-mobile-navAndRoute.html

/**
     * 打开腾讯地图
     * params 参考http://lbs.qq.com/uri_v1/guide-route.html
     *
     * @param context
     * @param dqAddress
     * @param gotoAddress
     * @param gotoLatitude
     * @param gotoLongitude
     * 驾车:type=drive,policy有以下取值
    0:较快捷
    1:无高速
    2:距离
    policy的取值缺省为0
     * &from=" + dqAddress + "&fromcoord=" + dqLatitude + "," + dqLongitude + "
     */
    public void openTencentMap(Context context, String dqAddress, String gotoAddress, String gotoLatitude, String gotoLongitude) {
        try {
            if (context != null && !StringUtlis.isEmpty(dqAddress) && !StringUtlis.isEmpty(gotoAddress) && !StringUtlis.isEmpty(gotoLatitude) && !StringUtlis.isEmpty(gotoLongitude)) {
                //double[] gotoLang=AMAPUtils.getInstance().bdToGaoDe(Double.parseDouble(gotoLatitude),Double.parseDouble(gotoLongitude));
                //gotoLatitude=String.valueOf(gotoLang[0]);gotoLongitude=String.valueOf(gotoLang[1]);
                String url1 = "qqmap://map/routeplan?type=drive&to=" + gotoAddress + "&tocoord=" + gotoLatitude+ "," +gotoLongitude  + "&policy=2&referer=myapp";
                Intent intent = new Intent("android.intent.action.VIEW", android.net.Uri.parse(url1));
                context.startActivity(intent);
            }
        } catch (Exception e) {

        }
    }

你可能感兴趣的:(地图导航,Android)