【问题标题】:Adding Google Navigation to my Android application将 Google Navigation 添加到我的 Android 应用程序
【发布时间】:2012-04-21 11:39:31
【问题描述】:

是否可以将 Google 导航添加到我的 Android 应用程序。我的想法是在应用程序上设置一个按钮,单击该按钮会打开谷歌地图,以便用户可以看到他们在哪里以及如何导航到我选择的本地地图上的某些兴趣点。

或者,是否有任何我可以使用的开源导航,以及如何将它用于我的 Android 应用程序以添加用户导航功能?

【问题讨论】:

    标签: android navigation userlocation


    【解决方案1】:
    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;
    }
    

    你可以在你的点击事件中有代码..

    【讨论】:

    • 这不是谷歌导航,而是谷歌地图。不一样。
    猜你喜欢
    • 1970-01-01
    • 2016-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多