|
|
第1行: |
第1行: |
− | {{vehicle-sidebar}}<div class="h1-title">百度地图车机版</div><div class="bluetitle"><div class="services-title-text service-page-anchor">1.简介</div></div><div class="serve-explain-text">
| |
− | 百度地图车机版open control调用协议是面向各OEM车企、车内相关零部件供应商、车机/车镜系统方案商、第三方开发者提供的一种可被第三方(系统或应用)调用百度地图车机版(以下简称bdmap)的方法,以满足某些特定业务场景下需求的接口。
| |
− | </div><div class="bluetitle"><div class="services-title-text service-page-anchor">2.功能介绍</div></div>
| |
− | {| border="1" cellspacing="1" cellpadding="1" style="width: 807px;"
| |
− | |-
| |
− | ! scope="col" style="width: 107px;" | 分类
| |
− | ! scope="col" style="width: 693px;" | 介绍
| |
− | |-
| |
− | | style="width: 89px; text-align: center;" | 图区功能
| |
− | | style="width: 675px;" | 地图首页内一些功能设置和页面跳转等功能
| |
− | |-
| |
− | | style="width: 89px; text-align: center;" | 数据透出
| |
− | | style="width: 675px;" | 可向外透传的信息,比如导航中诱导信息等
| |
− | |-
| |
− | | style="width: 89px; text-align: center;" | 导航
| |
− | | style="width: 675px;" | 发起特定地址的导航、路线规划等功能
| |
− | |-
| |
− | | style="width: 89px; text-align: center;" | 搜索
| |
− | | style="width: 675px;" | 沿途搜等
| |
− | |}
| |
− | <div class="bluetitle"><div class="services-title-text service-page-anchor">3.适用环境</div></div> 本文档所描述的接口适用于车机系统、车镜系统和运行在前两个系统平台上面的第三方应用程序。<div class="bluetitle"><div class="services-title-text service-page-anchor">4.基于Service | AIDL调用方法</div></div><div class="serveintoor-title"> 4.1 调用示例</div><pre class="prettyprint codestyle">private static final String REQUEST_ACTION =
| |
− | "com.baidu.baidumaps.opencontrol.ACTION.REQUEST";
| |
| | | |
− | private static final String SERVICE_KEY_PACKAGE_NAME = "package_name";
| |
− | private static final String SERVICE_KEY_SDK_VERSION = "version";
| |
− | private static final String SERVICE_KEY_ACTION = "content";
| |
− |
| |
− | private static final String BAIDU_MAP_PACKAGE = "com.baidu.BaiduMap.auto";//百度地图车机版使用调用这条
| |
− | private static final String BAIDU_MAP_PACKAGE = "com.baidu.BaiduMap.mirror";//百度地图车镜版使用调用这条
| |
− | private static final String SDK_SERVICE_CLASS = "com.baidu.mapframework.opencontrol.service.OpenControlService";
| |
− | private static final String SDK_VERSION = "1.0.0";
| |
− |
| |
− |
| |
− | //调用者包名称,调用服务成功后,会回调调用者的 KEY_CALLER_PACK_NAME + ".BDEntryService" 服务
| |
− | private static final String KEY_CALLER_PACK_NAME = "com.baidu.testDemon.opencontrol";
| |
− | // 此处为消息标识,回调消息时,会返回相同的transaction,用于做消息的对应
| |
− | private static final String SERVICE_KEY_TRANSACTION = "transaction";
| |
− | // 调用接口类型标识,具体看下表
| |
− | private static final String KEY_FUNCTION = "method";
| |
− | // 调用接口传参,具体看下表
| |
− | private static final String KEY_PARAMS = "param";
| |
− |
| |
− | private void sendRequest(String function, JSONObject param) throws JSONException {
| |
− |
| |
− | JSONObject jsonAction = new JSONObject();
| |
− | jsonAction.put(KEY_FUNCTION, function);
| |
− | jsonAction.put(KEY_PARAMS, param);
| |
− | String action = jsonAction.toString();
| |
− |
| |
− | Intent intent = new Intent();
| |
− | intent.setAction(REQUEST_ACTION);
| |
− | intent.setPackage(BAIDU_MAP_PACKAGE);
| |
− | intent.setClassName(BAIDU_MAP_PACKAGE, SDK_SERVICE_CLASS);
| |
− | intent.putExtra(SERVICE_KEY_PACKAGE_NAME, KEY_CALLER_PACK_NAME);
| |
− | intent.putExtra(SERVICE_KEY_SDK_VERSION, SDK_VERSION);
| |
− | intent.putExtra(SERVICE_KEY_ACTION, action);
| |
− | intent.putExtra(SERVICE_KEY_TRANSACTION, "t" + System.currentTimeMillis() + function);
| |
− | startService(intent);
| |
− | }
| |
− |
| |
− | </pre>
| |
− | <div class="serveintoor-title"> 4.2 返回示例</div><pre class="prettyprint codestyle">private static final String INTENT_KEY_CONTENT = "content";
| |
− | // 消息标识
| |
− | private static final String INTENT_KEY_TRANSACTION = "transaction";
| |
− | // 调用方法
| |
− | private static final String RESPOND_KEY_METHOD = "method";
| |
− | // 调用结果
| |
− | private static final String RESPOND_KEY_STATUS = "status";
| |
− | // 返回内容
| |
− | private static final String RESPOND_KEY_RESULT = "result";
| |
− |
| |
− |
| |
− | private void showRespond(Bundle extras) {
| |
− | String content = extras.getString(INTENT_KEY_CONTENT);
| |
− |
| |
− | try {
| |
− | JSONObject contentJson = new JSONObject(content);
| |
− | String method = contentJson.getString(RESPOND_KEY_METHOD);
| |
− | String status = contentJson.getString(RESPOND_KEY_STATUS);
| |
− | String content1 = contentJson.getString(RESPOND_KEY_RESULT);
| |
− |
| |
− | } catch (JSONException e) {
| |
− | }
| |
− | }
| |
− | </pre>
| |
− | <div class="bluetitle"><div class="services-title-text service-page-anchor">5.BroadCast广播</div></div><div class="serveintoor-title"> 5.1 广播协议</div><pre class="prettyprint codestyle">//action 对应业务模块
| |
− | //method 对应相应功能
| |
− |
| |
− | public final static String NOTIFY_OBSERVER_ACTION_NAVI_STATUE = "com.baidu.map.auto.NOTIFY.ACTION_NAVI_STATUE"; // 通知消息的主键,导航状态
| |
− | public final static String NOTIFY_OBSERVER_ACTION_NAVI_INDUCED= "com.baidu.map.auto.NOTIFY.ACTION_NAVI_INDUCUD"; // 通知消息的主键,诱导
| |
− | public final static String NOTIFY_OBSERVER_ACTION_MAP_INFO= "com.baidu.map.auto.NOTIFY.ACTION_MAP_INFO"; // 通知消息的主键,地图信息
| |
− | public final static String NOTIFY_OBSERVER_ACTION_ROUTE_INFO= "com.baidu.map.auto.NOTIFY.ACTION_ROUTE_INFO"; // 路线规划相关信息
| |
− |
| |
− | </pre>
| |
− | <div class="serveintoor-title"> 5.2 返回示例</div><pre class="prettyprint codestyle">//返回 key-value content json 字符串
| |
− | //key-value content 包含
| |
− | //method 调用的方法
| |
− | //result 返回内容
| |
− |
| |
− | //具体格式:
| |
− |
| |
− | private void sendBroadcast(String action, String method, String value) {
| |
− |
| |
− | try {
| |
− |
| |
− | Context context = JNIInitializer.getCachedContext();
| |
− | Intent intent = new Intent();
| |
− | intent.setAction(action);
| |
− |
| |
− | JSONObject json = new JSONObject();
| |
− | json.put("method",method);
| |
− | if (value != null){
| |
− | json.put("result",value);
| |
− | }
| |
− |
| |
− | intent.putExtra("content",json.toString());
| |
− | context.sendBroadcast(intent);
| |
− |
| |
− | } catch (Exception e) {
| |
− | MLog.e("sendBroadcast", "sendBroadcast error", e);
| |
− | }
| |
− | }
| |
− | </pre>
| |