Map navigation intent for all apps [mount route]

0

I'm looking for a way to give users the option to select which app to mount their route (waze, google maps, uber ...), but it just does not work in google maps.

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

Selecting google maps to open the route

Currently I'm doing 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}")

It really opens the google maps navigation cute, but it stops working in all other apps.

I would like a way that works for everyone.

    
asked by anonymous 21.08.2018 / 14:34

2 answers

0

I will leave here as I managed to help anyone who encounters the same problem

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

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()
    }
    
21.08.2018 / 16:05