google map Travel mode: request a ride - android

is it possible to change travel mode google maps to request a ride tab on android when click button from my app?
i used :
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?daddr="+ mLocation.latitude + ","+ mLocation.longitude +"&f=d&dirflg=r"));
startActivity(intent);
but parameter dirflg only limited to:
dirflg=h - Switches on "Avoid Highways" route finding mode.
dirflg=t - Switches on "Avoid Tolls" route finding mode.
dirflg=r - Switches on "Public Transit" - only works in some areas.
dirflg=w - Switches to walking directions - still in beta.
dirflg=d - Switches to driving directions

Seems (request a ride -> taXi) and:
dirflg=x - Switches on "request a ride tab" - only works in some areas.
and you can use intent with request like this:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=-7.328306+112.715478&daddr=Jl.+Frontage+Ahmad+Yani+Siwalankerto&dirflg=x"));
startActivity(intent);
to get result like that:
(replace -7.328306+112.71547 by mLocation.latitude + "+"+ mLocation.longitude for your LatLng in request)

Related

Android Auto NAVIGATE_INTENT Handling In Here Map shows no result.But works with google maps

Need to navigate from my android auto app car screen to Here maps app with geo coordinates. With google maps and waze I am able to start navigation. But Here map showing no results found.
Intent intent = new Intent(CarContext.ACTION_NAVIGATE)
.setData(Uri.parse("geo:13.11978,+80.14994"));
getCarContext().startCarApp(intent);
https://developer.android.com/training/cars/apps/navigation#support-navigation-intents
Is this because Navigation Intent is not handled. Any other methods to route navigation to here maps in android auto.
Try this:
Intent intent = new Intent(CarContext.ACTION_NAVIGATE)
.setData(Uri.parse("geo=0,0?q=N Park St,+Secretariat Colony,+Venkatapuram,+Ambattur,+Chennai,+Tamil Nadu 600053,+India"));
getCarContext().startCarApp(intent);
Check format No. 2 in this documentation:
https://developer.android.com/reference/androidx/car/app/CarContext#startCarApp(android.content.Intent)

Launch Android Google Maps in directions mode, with "Avoid Highways"

In my Android app, I am trying to launch Google Maps in directions mode with "Avoid Highways" selected.
Using this code, I can launch Gmaps in turn-by-turn mode with "Avoid Highways":
public void openMapsApp(String destinationCoords)
{
Uri gmmIntentUri = Uri.parse("google.navigation:q="+destinationCoords+"&avoid=h");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
startActivity(mapIntent);
}
However, I want to launch Gmaps in directions mode, not turn-by-turn navigation mode. I want to do this because I want the user to be able to quickly change their destination without having to exit out of navigation mode first.
In my attempt at doing this, I change one line to:
Uri gmmIntentUri = Uri.parse("https://maps.google.com/?saddr=My+location&daddr="+destinationCoords+"&dirflg=h");
And this does launch Gmaps into directions mode. However, for some strange reason, dirflg=h stops working. This URL does set 'avoid highways' to true when I open it in a web browser, but for some reason it doesn't when I launch Gmaps.
What's extra strange is that in my app if I use a different value like dirflg=w or dirflg=r it launches Gmaps in walking and transit directions, respectively. It's only dirflg=h that doesn't work.
Anyone have any ideas?
Never mind, I resolved it by using dirflg=dh !!!!

Google Maps avoiding tolls, highways or ferries in turn by turn navigation intent

I am using Google Maps turn by turn navigation in my app to navigate from the current location to a given address. It works fine, my only problem is that I cannot set up avoid tolls/highways/ferries options via intent.
I followed google descriptions here: https://developers.google.com/maps/documentation/android-api/intents#launch_turn-by-turn_navigation
My code is the following with avoid tolls parameter:
String navigation = "google.navigation:q=" + latLng.latitude + "," + latLng.longitude + "&avoid=t";
Uri uri = Uri.parse(navigation);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);
Navigation starts fine, but it doesn't take notice of the avoid tolls parameter, it opens the driving route through roads, where tolls must be paid.
I also tried &dirflg=t and &avoid=tolls parameters, but no result.
Does anybody have some solution for this?
Thank you!
I think it's a bug in some of the android implementations on some devices.
I have the same problem. The same code runs fine on an A3 (2016), but not on an Xcover 3. Both on Lollipop (API 22) but on slightly different versions (newer on the A3). Maybe an update will help.

android app invoking google map with car,public,walking controls

Im having problems porting some functions of Iphone application to Android.
Basically iphone google map app that is invoked from this app looks like this
I have tried to copy similar behaviour using this pseudo code
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr="+LAT_POSITION+","+LONG_POSITION+"&daddr="+Lat+","+Lon + "&dirflg=w"));
startActivity(intent);
what it does it brings the android map app in this form
so then when i click show map i get
and then when i press back twice i get this
my questions are.
How I can get the (car,public,walk) controls overlay the map? just like in iphone app - on one screen (other elements too if possible)
additional question..
How I can enable showing map by default? (instead of textual directions, this is happening in android 2.2 - I have checked on samsung galaxy with froyo) , In 4.0 (emulator) the map is showing by default but still there are no overlay controls (car,public,walk).
You can use setComponent to explicitly tell the Maps app to use com.google.android.maps.MapsActivity to resolve the intent:
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=" + LAT_POSITION + "," + LONG_POSITION +
"&daddr=" + lat + "," + lon + "&dirflg=w"));
intent.setComponent(new ComponentName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity"));
startActivity(intent);
You should get the directions overlay but I'm not sure it will draw the route until the user hits "Go".
Of course this is "non API" and assumes that Maps is installed on the device and that Google will not change the internal packgage or class name for MapsActivity.

Android application need to detect if the user came back from Google Maps Intent

I'm making an App and I use the Google Maps navigation
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=" + mLat + "," + mLng + "&daddr=" + mLatitude + " , " + mLongitude + ""));
And if the user come back from this intent I want to show the rating bar for the place the user has navigated to.
Is startActivityForResult something I can use on Intent not from my application?
Or is there another way to detect the user did came back to my App?
I don't know if you can get back something from an Intent you just throw up in the air for Android to handle but...
I'd recommend showing the map within one of your own activity; this way you'd exactly know what the user has done and which pin they've selected. You can then setResult in that Activity and get back the information.
I know it involves little bit more of development but you'd have total control of the map view and what the user do there. I'm sure you've seen this but take a look.
http://developer.android.com/resources/tutorials/views/hello-mapview.html
-serkan

Categories

Resources