Application to give directions by gps on android?

Asked

Viewed 76 times

0

I was thinking about developing an android app for bus/bus users to find stops. The idea would be to have my coordinates the coordinates of the stop and see the distance , but I also need indications for example 30 meters forward 20 to the right or simply open google maps and show a line of the point where I am until stop by the fastest way, someone knows if android allows to do this ? if yes how ?

1 answer

0


If I’m not mistaken, the Google Maps Map API allows starting a Intent that provides this navigation between the current location and a defined point, as if it were a GPS browser.

I can’t tell if he calculates the shortest distance, because the documentation provides little information about it.

It’s quite simple at first, just create the Intent and start:

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);

mapIntent.setPackage("com.google.android.apps.maps");

startActivity(mapIntent);

The documentation makes it clear that the q accepts addresses or a geographical position:

google.navigation:q=a+street+address
google.navigation:q=latitude,longitude

Of course you will create a dependency on Google Maps, which may not be available on the device (you will know why...)

But it is good to do the following check before starting to not cause a crash in the app:

if (mapIntent.resolveActivity(getPackageManager() != null) {
    startActivity(mapIntent);
} else {
    Toast.makeText(this, "Google Maps não está disponível!", Toast.LENGTH_LONG).show();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.