I am developing an application using Xamarin Forms (cross-platform) and I am trying to open a Waze application from my application, passing latitude and longitude.
It opens Waze very well, but Waze is just open, it did not try to find the address or latitude / longitude that I went through.
Some ideas on how I can make it work?
--- EDIT ---
Finally, he WORK using the idea of @SushiHangover, I managed to achieve the desired result. The final code is here:
public static Task<bool> OpenWazeAndroid(decimal latitude, decimal longitude, string address) { if (IsAndroid()) { try { var lat = latitude.ToString().Replace(",","."); var longi = longitude.ToString().Replace(",", "."); const string wazePrefix = "waze://"; Android.Content.Intent intent = new Android.Content.Intent(Android.Content.Intent.ActionView, Android.Net.Uri.Parse(wazePrefix)); string wazeURL = ("https://waze.com/ul?q=" + address + "&ll=" + lat + "," + longi + "&z=8&navigate=yes"); wazeURL = wazeURL.Replace(" ", "%20"); var resolveInfo = Android.App.Application.Context.PackageManager.ResolveActivity(intent, 0); Android.Net.Uri wazeUri; if (resolveInfo != null) { wazeUri = Android.Net.Uri.Parse(wazeURL); } else { wazeUri = Android.Net.Uri.Parse("market://details?id=com.waze"); } intent.AddFlags(Android.Content.ActivityFlags.NewTask); intent.SetData(wazeUri); Android.App.Application.Context.StartActivity(intent); return Task.FromResult(true); } catch (Exception ex) { App.Shell.Alert("Erro ao abrir o Waze.\n" + ex.Message); return Task.FromResult(false); } } return Task.FromResult(false); }
source share