Hello I'm using built in Google Map to show route to user. When I click on get route button I开发者_Python百科 have written the following code.
String mapURL="http://maps.google.com/mapssaddr="
+GlobleVeriable.getCurrentLocation().getLatitude()+","+GlobleVeriable.getCurrentLocation().getLongitude()+"&daddr="+restaurant.getLatitude()
+","+restaurant.getLongitude();
Intent i=new Intent("android.intent.action.VIEW",Uri.parse(mapURL));
startActivity(i);
This code Works fine and also displayed route from current location to destination location.. When I come back to my application from Google Maps ,my application start from first.
Can any one suggest me what to do?
Can you please try the code below
String uri="http://maps.google.com/mapssaddr="
+GlobleVeriable.getCurrentLocation().getLatitude()+","+GlobleVeriable.getCurrentLocation().getLongitude()+"&daddr="+restaurant.getLatitude()
+","+restaurant.getLongitude();
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
It's just the average Android behavior. What you can do is to save the current state of the application to some file, right before starting the Google Maps activity. On resume, you can load that file and restore the application manually.
I think it's the only way. It's been a while since I browsed the Android documentation. I do remember something like "... the operating system may terminate your application at any time if inactive, so it's the developer's responsibility to save any user-sensitive information before the application goes inactive".
I'd save within the onPause() method, and load within onResume().
精彩评论