8

I am developing turn by turn navigation from current location to destination. I done this by using below code

Uri gmmIntentUri = Uri.parse("google.navigation:q="+address);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

The problem is that if click back in screen 1 it takes to screen 2. Then if i click back in screen 2 it takes to screen 3, then screen 4, then finally my activity.

What i want is if click back in screen 1, how can i take to my activity? how can i finish screen2, screen3, screen4 by clicking on back in screen1?

screen 1:

enter image description here

screen 2:

enter image description here

screen 3:

enter image description here

screen 4:

enter image description here

selva_pollachi
  • 4,147
  • 4
  • 29
  • 42

3 Answers3

1

For this May be the Below Solution works i am not sure but let you try with this.

Start the Screen 2,3 with android:noHistory="true" in its manifest entry.

Launch the Screen 4 with the Intent

Rajan Bhavsar
  • 1,977
  • 11
  • 25
0

Put to your intent the flag FLAG_ACTIVITY_PREVIOUS_IS_TOP

Uri gmmIntentUri = Uri.parse("google.navigation:q="+address);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
mapIntent.setFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
startActivity(mapIntent);

` From the android documentation:

If set and this intent is being used to launch a new activity from an existing one, the current activity will not be counted as the top activity for deciding whether the new intent should be delivered to the top instead of starting a new one. The previous activity will be used as the top, with the assumption being that the current activity will finish itself immediately.

newhouse
  • 946
  • 8
  • 12
0

Call intent like this in Screenshot2.class, Screenshot3.class

Intent in =new Intent(Screenshot2.this, Screenshot3.class);
                        finish();
                        startActivity(in);
Mel
  • 5,837
  • 10
  • 37
  • 42
sarika kate
  • 489
  • 2
  • 7