Navigation Intent on Android is not working - android

I would like to call a navigation Intent using given source and destination point, by the way I am trying these codes
Intent navIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(http://maps.google.com/maps?saddr="sourcelat&long"&daddr="destinationlat&long"&mode="driving"));
navIntent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");startActivity(navIntent);
As per the method above I am getting the navigation fine but by default destination address is taken as current location eventhough we are passing the destination address. so my need is that device should not take destination address as current device location instead it should take from Intent as we are passing . Please suggest me how to solve this.
Regards
Priya

You can do it this way i think.
But it use Google Maps and not Google Navigation.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);
Source: Google Navigation intent

Related

Launch Google Navigation without routes choosing

I am launching Google Navigation with intent:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + mCity));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
It build route from my current location to destination city. But sometimes it give me few routes. Is there way to force give me always only one route?
It is just launching Google Navigation app with destination and current address, so it will depend on user to choose one route as is case with regular navigation app.

Is it possible to programmatically access the Google Maps' navigation history?

I wonder if it possible to retrieve the Google Maps navigation history. In other words, is there a way of retrieving the recent routes taken/searched by the user of the Google Maps app?
Thanks
You can not finish Google Navigation App.
There is only one work around which I found,
Re-start the navigation with the current location, hence the navigation will automatically be finished.
public static void startNavigationIntent(Context activity, String destination)
{
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + destination));
activity.startActivity(intent);
}
And then bring your app to the foreground.
Intent bringToForegroundIntent = new Intent(BackgroundLocationService.this, DashboardActivity.class);
bringToForegroundIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(bringToForegroundIntent);
There is no API available to get information out of the Navigation App. But you can feed some data to Maps to request a route through an Intent / URI.
But I don't think that the Maps app will save the whole route anyway, only the destination. The user selects any saved destination and you can get there from any source.

Launch directly the directions on Google Maps

I want to launch the Google Maps app from my android application with the driving directions view.
I gone through the following posts but they don't serve my purpose.
Launch Google Maps to show road directions
How to programmatically launch map appliction in android to show direction?
I tried the following code...
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?f=d&daddr=51.448,-0.972"));
intent.setComponent(new ComponentName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity"));
startActivity(intent);
Which gives me the following view,
Then I need to click 'Get Directions' button to get the following view,
And then I need to click 'DIRECTIONS LIST' to get the following view,
Is there a way to directly launch the 3rd view (as above) from my android application?
Yes You can directly open direction view Using google.navigation.
Just pass Destination address and it will give direction from current location to destination address:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=destination address"));
startActivity(intent);

Open default navigation app using an address

How can i start an Intent to open either the default navigation application (e.g. Google Navigation or Google Maps) or give the user the opportunity to select among navigation applications.
Thanks in advance.
You have to use an Intent with ACTION_VIEW and the geo data scheme.
The problem using geo:latitude,longitude is that Google Maps only centers at your point, without any pin or label.
That's quite confusing, especially if you need to point to a precise place or/and ask for directions.
If you use the query parameter geo:lat,lon?q=name in order to label your geopoint, it uses the query for search and dismiss the latitude and longitude parameters.
I found a way to center the map with latitude and longitude and display a pin with a custom label, very nice to display and useful when asking for directions or any other action:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=37.423156,-122.084917 (" + name + ")");
startActivity(intent);
This intent is from the list of official "G apps" intent list here.
Try:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=New+York+NY")); startActivity(i);
Or use this, this way the stardard navigation app will be launched:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);
Add this line before startActivity if you don't want the popup dialog:
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
Also see: How to check programmatically if an application is installed or not in Android? and Android: detect when app is installed, you can make your own Window so the user can choose between some application.

Problem launching Google Navigation

i tried since many hours to launch navigation from my app.
I want navigation without destination.
i tried with
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q="));
startActivity(i);
That launches navigation but with destination not found
I tried too to launch processName, packageName with startIntent with com.google.android.apps.maps,
com.google.android.apps.maps:driveabout and
**com.google.android.maps.driveabout.app.DestinationActivity
with no succes too :/
an idea ?
Google Navigation does not have any documented and supported Intent filters. It is not designed to be integrated from third party apps.
The following code should work...
String url = "google.navigation:q="+startPos.getLatitude()+","+startPos.getLongitude();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
Take a closer look a the intent filter for Google Navigation. It could be that it is not designed to be started via Intent without a specified destination. Unfortunately, i don't know where to find information about Google Navigation's intent filter, but if you were to show me where you are looking i could help you figure it out.
Try using
google.navigation:fd=true
i don't want to integrate it, i just want to launch it like a click on the list of apps whith a home launcher.
I've tried the google home sample, and navigation can be launched.
but i don't understand why that doesn't work with my own app :/

Categories

Resources