簡體   English   中英

如何通過android上的意圖啟動“谷歌地圖導航”

[英]How to launch "Navigation for google maps go" via an intent on android

我正在開發一個具有通過 Intent 鏈接到“Google 地圖”以顯示方向的功能的應用程序,它可以與使用 Google 地圖的設備一起使用。 但是在某些設備中使用“Google map go”和“Navigation for google map go”,似乎這些應用程序不像“Google map”那樣處理 Intent。

我試圖用“谷歌地圖”和“谷歌地圖導航”包替換“歌地圖”包。 但它不起作用。

Uri gmmIntentUri = Uri.parse("google.navigation:q=" + destinationPoint.latitude + "," + destinationPoint.longitude + "&mode=d");

Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.navlite");

context.startActivity(mapIntent);

我進行了研究,但找不到任何關於此的文檔,那么該怎么做呢?

String uri = String.format(Locale.ENGLISH, "geo:%f,%f?z=%d&q=%f,%f(%s)",
                latitude, longitude, 16, latitude, longitude,
                "Your Location TEXT");

        //Try for google Maps 1st.
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        intent.setPackage("com.google.android.apps.maps");
        try
        {
            (getContext()). startActivity(intent);
        }
        catch(ActivityNotFoundException ex)
        {
            try
            {//Now try for GO MAPS / Browser
                uri = "http://maps.google.com/maps?daddr=" + latitude + "," + longitude ;



                Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                (getContext()).startActivity(unrestrictedIntent);
            }
            catch(ActivityNotFoundException innerEx)
            {//Finally show a toast.
                Toast.makeText((v.getContext().getApplicationContext()),
                        "Install Google maps") , Toast.LENGTH_LONG).show();
            }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM