Search code examples
androidgoogle-mapskotlinmapswaze

Starting navigation with android intent


I have method which start navigation on external app. Method working well with google maps and sygic. But users started to reporting they can open navigation even with Waze but no data is transported via intent (so they see only waze main screen).

I found right uri to launch waze but then I'll loose other options.

private fun startNavigation(lat: Double, lon: Double) {
    val uri = "google.navigation:q=$lat,$lon" //google maps, sygic - ok, waze - fail
    //val uri = "waze://?ll=$lat,$lon&navigate=yes" //waze only
    //val uri = "google.navigation:q=$lat,$lon&ll=$lat,$lon&navigate=yes" //google maps, waze - ok, sygic - fail

    startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(uri)))
}

I missing something here? Is there any universal option how to support all possible applications or should I make custom bottom sheet to handle it by myself for most used?


Solution

  • Unfortunately there is no general intent for navigation. So you must take care of apps you want to support and open them via Intent.ACTION_VIEW

    Try setting waze url like this:

    val wazeUrl = "https://waze.com/ul?ll=$latitude%2C$longitude&navigate=yes"
    

    For further information have a look at this medium post