Android调用第三方百度APP进行导航

一 判读是否安装百度地图

/**
 * 根据包名检测某个APP是否安装
 * <h3>Version</h3> 1.0
 * <h3>CreateTime</h3> 2016/6/27,13:02
 * <h3>UpdateTime</h3> 2016/6/27,13:02
 * <h3>CreateAuthor</h3>
 * <h3>UpdateAuthor</h3>
 * <h3>UpdateInfo</h3> (此处输入修改内容,若无修改可不写.)
 * @return true 安装 false 没有安装
 */
public static boolean isInstalled() {
    return new File("/data/data/com.baidu.BaiduMap").exists();
}
二 通过经纬度导航

/**
 * (此处输入方法执行任务.)
 * <h3>Version</h3> 1.0
 * <h3>CreateTime</h3> 2017/11/9,15:31
 * <h3>UpdateTime</h3> 2017/11/9,15:31
 * <h3>CreateAuthor</h3>
 * <h3>UpdateAuthor</h3>
 * <h3>UpdateInfo</h3> (此处输入修改内容,若无修改可不写.)
 * @param context 上下文
 * @param coord_type coord_type 可选 坐标类型,可选参数,默认为bd09经纬度坐标
 * @param src  必选 调用来源,规则:companyName|appName。
 * @param location 经纬度 例如:39.9761,116.3282
 */
public static  void invokeNavi(Context context, String coord_type , @NonNull String src,@NonNull String location){
    StringBuffer stringBuffer  = new StringBuffer("baidumap://map/navi?");
    if (!TextUtils.isEmpty(coord_type)){
        stringBuffer.append("coord_type=").append(coord_type);
    }
    stringBuffer.append("&src=").append(src);
    stringBuffer.append("&location=").append(location);
    Intent intent = new Intent();
    intent.setData(Uri.parse(stringBuffer.toString()));
    context.startActivity(intent);
}

三 通过关键字导航

/**
 * (此处输入方法执行任务.)
 * <h3>Version</h3> 1.0
 * <h3>CreateTime</h3> 2017/11/9,15:31
 * <h3>UpdateTime</h3> 2017/11/9,15:31
 * <h3>CreateAuthor</h3>
 * <h3>UpdateAuthor</h3>
 * <h3>UpdateInfo</h3> (此处输入修改内容,若无修改可不写.)
 * @param context 上下文
 * @param coord_type coord_type 可选 坐标类型,可选参数,默认为bd09经纬度坐标
 * @param src  必选 调用来源,规则:companyName|appName。
 * @param query 关键字 例如:故宫
 */
public static  void invokeNavi2(Context context, String coord_type , @NonNull String src,@NonNull String query){
    StringBuffer stringBuffer  = new StringBuffer("baidumap://map/navi?");
    if (!TextUtils.isEmpty(coord_type)){
        stringBuffer.append("coord_type=").append(coord_type);
    }
    stringBuffer.append("&src=").append(src);
    stringBuffer.append("&query=").append(query);
    Intent intent = new Intent();
    intent.setData(Uri.parse(stringBuffer.toString()));
    context.startActivity(intent);
}

官方文档:

http://lbsyun.baidu.com/index.php?title=uri/api/android#service-page-anchor10



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值