2013-01-16 67 views

回答

1

嘗試:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=New+York+NY")); startActivity(i); 

或者利用這一點,這樣的導航參考標準的應用程序將被啓動:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345")); 
startActivity(intent); 

startActivity前加入這一行,如果你不想要的彈出對話框:

intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); 

另請參閱:How to check programmatically if an application is installed or not in Android?Android: detect when app is installed,您可以自己製作窗口讓用戶可以在一些應用程序中進行選擇。

+0

我嘗試了兩個建議,但第一個只是打開Goog​​le導航,另一個只打開選擇的可能性:(我的兩個瀏覽器或谷歌地圖,而不是谷歌導航) – Noloxs

+0

查看我編輯的文章 – ObAt

+0

我希望它可以選擇Google地圖和Google導航,也可以選擇用戶可能已安裝的任何應用程序來導航或獲取路線。 但我甚至不知道這是否可能。 – Noloxs

1

您必須將ACTION_VIEW和geo數據方案與Intent一起使用。

使用geo:latitude,longitude時出現的問題是,Google地圖只能集中在您的位置,沒有任何圖釘或標籤。

這很混亂,特別是如果你需要指向一個精確的地方或/並要求方向。

如果您使用查詢參數geo:lat,lon?q=name來標記您的地址,它將使用查詢進行搜索並關閉經度和緯度參數。

我找到了一種方法,以中心經度和緯度的地圖,並顯示與自定義標籤針,非常不錯的顯示和有用的問路或任何其他操作時:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("geo:0,0?q=37.423156,-122.084917 (" + name + ")"); 
startActivity(intent); 

這個意圖是從官方「G應用程序」意向清單列表here

相關問題