i am working with Google Maps navigation in my Android application ...
When calling Google Maps navigation's Intent from MainActivity Google Map Showing route path completely in my device but now when press back button from Google Maps it close whole application instead go back to MainActivity so i need to go back my MainActivity on Back pressed in Map activity...
My code for calling map activity
String strURL = new StringBuilder()
.append("http://maps.google.com/maps?saddr=")
.append(src_lat).append(",").append(src_long)
.append("&daddr=").append(dest_lat).append(",")
.append(dest_long).toString();
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(strURL));
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
Can any one help me ??? how to catch back pressed event from Google Maps navigation's Intent ...
You should use startActivityForResult(); and make sure your activity doesn't have any propertly like singleinstance or singleTop.
Related
So I am building a map that shows locations (markers). I don't want to use the Map ToolBar (which has directions and open in Google Maps button) however I do want to make my own button that opens in GoogleMaps with directions to that marker.
try this:
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);
Or if not working try this according to this link https://developers.google.com/maps/documentation/urls/guide:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393"));
startActivity(intent);
I have navigated to maps application from myapplication using following code
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
when i press back button in maps it navigates to my application.
When i minimize maps application and open maps from recently open list apps and press back button, My application is not opening.
Could any help me on this ?
Do i need to add any flags to intent to open my application in second case ? or any idea please suggest me..
It seems to me you should set android:alwaysRetainTaskState true in your root activity.
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.
I have an application get direction via google map. Example Activity A call google map:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(myuri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
It show
Image 1: http://flic.kr/p/eBnRCy
then show
Image 2: http://flic.kr/p/eBjGWn
How to from image 2, I can back again my application(Activity A), don't back again image 1. Thanks a lot.
You may try to hack it with Intent.FLAG_ACTIVITY_NO_HISTORY, which removes first Activity as soon as a second is opened. This will work if the two screens you put into question are two instances of Activity (even if they are the same class).
This is probably really stupid of me but how do I start google navigation WITHOUT setting a location as a lot of issues seem to come from... When I try to do this it actually starts to run Google Navigation but then just keeps restarting the Activity... Essentially I was it to run just like when you click on Navigation like you would from a home screen... So with the list of destinations etc... I presume this is a different activity maybe? I've no idea, the intent I'm using is below,
Intent i = new Intent(Intent.ACTION_VIEW);
i.setClassName("com.google.android.apps.maps", "com.google.android.maps.driveabout.app.NavigationActivity");
getContext().startActivity(i);
Finally found what Activity it is that needs starting!!!
Intent i = new Intent();
i.setClassName("com.google.android.apps.maps","com.google.android.maps.driveabout.app.DestinationActivity");
startActivity(i);