Map navigation intent for all apps [mount route]

Asked

Viewed 204 times

0

I’m looking for a way to give user option select which app mount your route (Waze, google maps, Uber...), but just does not work on google maps.

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

Selecting google maps to open the route

Currently I’m doing so:

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

startActivity(mapIntent)

I know there’s a choice:

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

Really opens the navigation of cute google maps, but so stops working on all other apps.

I’d like a way that works for everyone.

2 answers

0


I’ll leave it here as I managed to help anyone who comes across the same problem

Uri.parse("geo:0,0?q=${mClient.lat},${mClient.lng}")

0

You can use this Xtension:

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()
    }
  • If you notice well, this is how I said I was using. I already found a solution, I commented right down

Browser other questions tagged

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