user3136364
user3136364

Reputation:

start google navigation and go back to my app android

i'm trying to open google navigation from my app ans when clicking "back" to go back to my app. i'm using this code:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + destination));
startActivity(intent);

but when pressing "back" the google navigation refreshing.

if i'm using startActivityForResult(intent, 1); the google navigation not opening.

Upvotes: 1

Views: 871

Answers (1)

AniV
AniV

Reputation: 4037

You have not set a Flag in your intent, Try this working code:

Intent navigation = new Intent( Intent.ACTION_VIEW, 
            Uri.parse("http://maps.google.com/maps?f=d&source=s_d" +
            "&saddr=xx.xxxxx,yy.yyyyy&daddr=xx.xxxxx,yy.yyyyy")); 
    navigation.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK&Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
   navigation.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    startActivity(navigation);

Hope this would Help!!

Upvotes: 1

Related Questions