我使用这些标志启动了下一个活动以清除后台堆栈。
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
并尝试过
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
这个我也加了。
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
但是所有的结果都是这样的。
D/activity-stack: idx: 0
num: 1, base-name: com.example.ui.result.ResultActivity, top-name: com.example.ui.result.ResultActivity
D/activity-stack: idx: 1
num: 1, base-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity, top-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity
D/activity-stack: idx: 0
num: 1, base-name: com.example.ui.result.OrderActivity, top-name: com.example.ui.result.OrderActivity
D/activity-stack: idx: 1
num: 1, base-name: com.example.ui.result.ResultActivity, top-name: com.example.ui.result.ResultActivity
D/activity-stack: idx: 2
num: 1, base-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity, top-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity
D/activity-stack: idx: 0
num: 1, base-name: com.example.ui.result.PaymentActivity, top-name: com.example.ui.result.PaymentActivity
D/activity-stack: idx: 1
num: 1, base-name: com.example.ui.result.OrderActivity, top-name: com.example.ui.result.OrderActivity
D/activity-stack: idx: 2
num: 1, base-name: com.example.ui.result.ResultActivity, top-name: com.example.ui.result.ResultActivity
D/activity-stack: idx: 3
num: 1, base-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity, top-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity
D/activity-stack: idx: 0
num: 1, base-name: com.example.ui.result.CompleteActivity, top-name: com.example.ui.result.CompleteActivity
D/activity-stack: idx: 1
num: 1, base-name: com.example.ui.result.OrderActivity, top-name: com.example.ui.result.OrderActivity
D/activity-stack: idx: 2
num: 1, base-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity, top-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity
如您所见,它只清除了最旧的一个。我怎样才能清楚地清除backstack?
我期望的是:
D/activity-stack: idx: 0
num: 1, base-name: com.example.ui.result.Completectivity, top-name: com.example.ui.result.CompleteActivity
D/activity-stack: idx: 1
num: 1, base-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity, top-name: com.google.android.apps.nexuslauncher.NexusLauncherActivity