日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Android中直接打开高德APP进行导航

發布時間:2023/12/15 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 Android中直接打开高德APP进行导航 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、判斷是否安裝有高德APP

//高德APP
private PackageManager mPackageManager;
private static List<String> mPackageNames = new ArrayList<>();
private static final String GAODE_PACKAGE_NAME = "com.autonavi.minimap";
private static final String BAIDU_PACKAGE_NAME = "com.baidu.BaiduMap";
/*private double currLocationX = 39.9076860000;
private double currLocationY = 116.4012450000;
private double locationX = 40.0836620000;
private double locationY = 116.4127900000;
private String storeName = "北京飯店";*/

private double currLocationX;//起點 緯度
private double currLocationY;//起點 經度
private double locationX;//終點 緯度
private double locationY;//終點 經度
private String storeName;//地點名稱




if(haveGaodeMap()){//如果安裝高德APP openGaodeMapToGuide();//打開高德APP } else {//否則 打開瀏覽器 openBrowserToGuide(); }

2、

 /**
     * 打開高德地圖
     * https://lbs.amap.com/api/amap-mobile/guide/android/route
     */
    private void openGaodeMapToGuide() {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        Log.i("高德定位:","經度:"+currLocationY+" ,緯度:"+currLocationX);
        if (currLocationX == 0.0 || currLocationY == 0.0){
            url = "androidamap://route?sourceApplication=amap&dlat="+locationX+"&dlon="+locationY+"&dname="+storeName+"&dev=0&t=1";
        }else {
            url = "androidamap://route?sourceApplication=amap&slat="+currLocationX+"&slon="+currLocationY
                +"&dlat="+locationX+"&dlon="+locationY+"&dname="+storeName+"&dev=0&t=1";
        }



        Uri uri = Uri.parse(url);
        //將功能Scheme以URI的方式傳入data
        intent.setData(uri);
        //啟動該頁面即可
        startActivity(intent);
    }


    /**
     * 打開瀏覽器
     */
    private void openBrowserToGuide() {
        String url = "http://uri.amap.com/navigation?to=" + locationY + "," + locationX + "," +
                storeName + "&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=0";
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }





    public void initPackageManager(){
        List<PackageInfo> packageInfos = mPackageManager.getInstalledPackages(0);
        if (packageInfos != null) {
            for (int i = 0; i < packageInfos.size(); i++) {
                mPackageNames.add(packageInfos.get(i).packageName);
            }
        }
    }

    /**
     * 判斷有無安裝高德
     * @return
     */
    public boolean haveGaodeMap(){
        initPackageManager();
        return mPackageNames.contains(GAODE_PACKAGE_NAME);
    }

總結

以上是生活随笔為你收集整理的Android中直接打开高德APP进行导航的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。