Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @OnClick(R.id.getDirections)
- void getDirections() {
- /** Start Navigation in Google Maps **/
- String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?&daddr=%f,%f (%s)", location.geolat, location.geolng, location.name);
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
- intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
- try
- {
- startActivity(intent);
- }
- catch(ActivityNotFoundException ex)
- {
- try
- {
- /** Start navigation in Waze **/
- uri = "geo: "+location.geolat+","+location.geolng;
- Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
- startActivity(unrestrictedIntent);
- }
- catch(ActivityNotFoundException innerEx)
- {
- Toast.makeText(this, "Please install a maps application", Toast.LENGTH_LONG).show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement