Map navigation Intent for all apps [Mount route]

I am looking for a way to give user option select which app ride their route (waze, google maps, uber...), but only does not work on google maps.

When I choose it, it only shows the location on the map, but does not open the navigation, as in the others.

Selecting google maps to open the Route

Currently I'm doing like this:

val gmmIntentUri = Uri.parse("geo:${mClient.lat},${mClient.lng}")
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)

startActivity(mapIntent)

I know there is the option to do:

Uri.parse("google.navigation:q=${mClient.lat},${mClient.lng}")

Actually opens the navigation of the google maps cute, but so it stops working in all other apps.

I would like a way that works for everyone.

Author: Iago Silva, 2018-08-21

2 answers

I'll leave here how I managed to help anyone who comes across the same problem

Uri.parse("geo:0,0?q=${mClient.lat},${mClient.lng}")
 0
Author: Iago Silva, 2018-08-21 13:50:14

You can use this extension:

fun Activity.openMaps(latitude: String, longitude: String) =
    try {
        val uri = "geo:$latitude,$longitude"
        startActivity(Intent(Intent.ACTION_VIEW,
                Uri.parse(uri)))
    } catch (e2: Exception) {
        Toast.makeText(this, "Não é possivel abrir a rota.", Toast.LENGTH_SHORT).show()
    }
 0
Author: LMaker, 2018-08-21 14:05:49