7

I have a simple Android app which should be able to allow navigation between 2 GeoPoint's.

I can easily display a GeoPoint on Waze, writing this small piece of code:

String uri = "waze://?ll=40.761043, -73.980545&z=10";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));

But, what I really need is a way to display navigation directions between 2 points. I've tried to locate the correct BroadcastReciever in the Waze source, but I stopped follow when it got to native calls (JNI) because I have no idea where the actual call is... I reached only to the URIHandler signature, with no success finding the implementation...

Any ideas?

Thanks.

ofirbt
  • 1,846
  • 7
  • 26
  • 41

5 Answers5

16

Fix you uri to:

String uri = "waze://?ll=40.761043, -73.980545&navigate=yes";

(added navigate=yes) and you should be good.

TalL
  • 1,661
  • 16
  • 16
14

If this is still relevant you can use this:

String uri = "geo: latitude,longtitude";
startActivity(new Intent(android.content.Intent.ACTION_VIEW,
                        Uri.parse(uri)));
Ami
  • 387
  • 3
  • 11
  • 3
    Is there a way to filter this so it will only start Waze? Because when I try it it gives the user an option to go to Google Earth instead. Google earth won't offer navigation so it's a crappy experience. – Ankhwatcher Apr 17 '14 at 11:20
  • @Ankhwatcher .. Did you find the solution ? – Android is everything for me Feb 20 '18 at 08:31
  • For anyone wanting to filter Activities, you can use PackageManager.queryIntentActivities(...) to filter out the Activities you don't want. Search Google for more info. – TheIT Jan 15 '19 at 21:39
  • Does not work for Waze currently, Android 13 (API level 31 for app): https://stackoverflow.com/questions/74145009/android-generic-way-to-reliably-start-navigation-activity-using-default-app – Ted Oct 20 '22 at 19:15
3

Today's Waze base url is https://waze.com/ul so to navigate you have to use

https://waze.com/ul?ll=45.6906304,-120.810983&navigate=yes
Claudio Redi
  • 67,454
  • 15
  • 130
  • 155
1

You can do [kotlin]:

fun openWaze(latitude: Double, longitude: Double) {
    packageManager?.let {
        val url = "waze://?ll=$latitude,$longitude&navigate=yes"
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
        intent.resolveActivity(it)?.let {
            startActivity(intent)
        } ?: run {
            Toast.makeText(context, R.string.noWazeAppFound, Toast.LENGTH_SHORT).show()
        }
    }
}
dairdr
  • 11
  • 2
0

According to Google doc about working with Waze you can use code below to open waze from your android app:

try {
    // Launch Waze to look for Hawaii:
    String url = "https://waze.com/ul?ll=40.761043,-73.980545&navigate=yes";
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(intent);
} catch (ActivityNotFoundException ex) {
    // If Waze is not installed, open it in Google Play:
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.waze"));
    startActivity(intent);
}
Payam Monsef
  • 296
  • 3
  • 6