0

Is it possible to add Google Navigation to my Android application. My idea is to have a button on the app, which when clicked, opens Google Maps so that the user can see where they are and how to navigate to certain Points Of Interest on my chosen local map.

Alternatively, is there any open-source navigation I can use and how could I harness it to my Android application in order to add in the user navigation functionality?

Kuda Nyadzo
  • 1
  • 1
  • 2

1 Answers1

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;
}

you can have the code in your click event..

Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64