2012-04-21 68 views
0

是否可以將Google導航添加到我的Android應用程序中。我的想法是在應用程序上有一個按鈕,當點擊該按鈕時,將打開Goog​​le地圖,以便用戶可以看到他們的位置以及如何導航到我選擇的本地地圖上的某些興趣點。將Google導航添加到我的Android應用程序

另外,是否有任何開源導航可以使用,以及如何將它用於我的Android應用程序以添加用戶導航功能?

回答

2
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=0,0%20(Imaginary%20Place)&dirflg=r")); 
if (isAppInstalled("com.google.android.apps.maps")) { 
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); 
} 
startActivity(intent); 



// helper function to check if Maps is installed 
private boolean isAppInstalled(String uri) { 
    PackageManager pm = getApplicationContext().getPackageManager(); 
    boolean app_installed = false; 
    try { 
     pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); 
     app_installed = true; 
    } catch (PackageManager.NameNotFoundException e) { 
     app_installed = false; 
    } 
    return app_installed; 
} 

你可以有代碼,在點擊事件..

+0

謝謝,現在我會努力的! – 2012-04-25 00:38:44

+1

這不是Google導航,而是Google地圖。不一樣。 – Ted 2013-01-18 16:43:47

+0

是否可以在webview中顯示導航? – Kirthiga 2014-06-30 11:11:53

相關問題