Search code examples
androidgoogle-mapsback-button

Android: Return to own app from Google Navigation by pressing once on back button


I'm a beginner for android. Your helps are really appreciated.
Description on code below: Once user click on a marker, they will be redirect to google navigation. So, when i am in google navigation page, is there any way to press on back button just once in order to back to my app? As now i need to press back button for a few times
(google navigation->google map-> myapp).

               @Override
                public boolean onMarkerClick(Marker arg0) {

                    String url="google.navigation:q="+Latitude+","+Longitude;
                    Intent intent2 = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(url));

                    Intent intent3 =Intent.createChooser(intent2, "Testing");

                    startActivity(intent2);

                    return false;
                }

            };

            map.setOnMarkerClickListener(markerclick);

Solution

  • Maybe I am wrong, but I don't think you can control that. You are not in your app anymore and you can not know how the other app (in this case, googlemaps, from what I understood) is going to organize its activities and fragments to handle the navigation. :/