Issue
Since Waze and Google Maps have different URI formats, I need to create two separate intents in order to make sure that apps will navigate user to the correct location.
The main problem: I don't want to make user select navigation app every time. I want it to behave like this: if user has default navigation app set - use it without asking.
How to have two URIs for separate apps but still have the same interface just like when starting intent with ACTION_VIEW
parameter?
This is my code that I am working with. Currently navigation works fine, but user is being asked every time to select navigation app:
if (!StringUtils.isEmpty(address)) {
String q = address + "&mode=d&navigate=yes&geo=" + address + "&ll=" + address;
String urlWaze = "https://waze.com/ul?q=" + q;
Intent wazeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlWaze));
String urlGoogle = "google.navigation:q=" + q;
Intent googleMapsIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlGoogle));
googleMapsIntent.setPackage("com.google.android.apps.maps");
String title = getActivity().getResources().getString(R.string.choose_navigation_app);
Intent chooserIntent = Intent.createChooser(wazeIntent, title);
Intent[] arr = new Intent[1];
arr[0] = googleMapsIntent;
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arr);
getContext().startActivity(chooserIntent);
} else {
Toast.makeText(getContext(), getString(R.string.waypoint_not_have_geolocation), Toast.LENGTH_SHORT).show();
}
Solution
As it turns out Waze and Google Maps have very different URIs and in ordet to resolve situation that I descibed in my question, the only solution was to create separate user-settings in my application.
Answered By - Marius
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.