繁体   English   中英

从自定义应用程序启动百度地图意图

[英]Launching Baidu Map intent from custom app

在我的应用程序中,我提供了一个发货地址。 当用户按下按钮时,它会启动一个意图,以该地址作为参数来谷歌地图。

String uri = String.format(Locale.ENGLISH, "google.navigation:q=" + shipmentAdress);
                                                    Intent intent = new Intent(Intent.ACTION_VIEW,
                                                            Uri.parse(uri));
                                                    startActivity(intent);

我想为我们在中国无法访问谷歌地图但可以访问百度地图的客户做同样的事情。 请记住,我没有 GPS 坐标,只有地址。

有谁知道我会怎么做? 他们所有的文档都是中文的,他们的应用程序也是如此,而我只使用谷歌翻译。

我已经把它归结为"baidumap://map/geocoder?src=openApiDemo&address="但它通常会返回并出错(我想,我使用了错误的屏幕截图和 Pleco 的 OCR 对其进行了某种翻译。)

最后想通了:

String uri = String.format(Locale.CHINA, "baidumap://map/navi?query=" + shipmentAdress);
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(uri));
startActivity(intent);

尝试使用此 Intent

try {
    Intent intent = Intent.parseUri("intent://map/marker?location=21.028399,105.790824&title=CV Cầu &content=Công viên vui chơi&src=yourCompanyName|yourAppName#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end", Intent.URI_INTENT_SCHEME);
    if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
        startActivity(intent);
    }
} catch (URISyntaxException e) {
    e.printStackTrace();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM