0

I'm trying to delete all screens from stack in android auto app with

screenManager.popToRoot().

But when I use it, it says that I have reached the 5 screen limit of the stack.

For example, if I'm doing this flow:

  1. Screen A
  2. Screen B
  3. Screen C
  4. Screen D
  5. Screen E

When I click on a button I created on screen E, I want to go back to Screen A and remove all stack.

Someone can tell me how I can do this? Thanks!

2 Answers2

0

Try to use popTo() method. you can set marker to your root screen. https://developer.android.com/reference/androidx/car/app/ScreenManager#popTo(java.lang.String)

TNT
  • 59
  • 4
-1

Try to do it manually, instead of using

screenManager.popToRoot()

Use

startActivity(new Intent(currentActivity.this, firstActivity.class))
finishAffinity()

Note that finishAffinity is used to finish all activities associated with the task, including all activities in the task's back stack. When finishAffinity() is called, the task's root activity and all activities below it in the back stack are finished.

Mokhtar Abdelhalim
  • 232
  • 1
  • 3
  • 9