0

I have 2 activity (Activity A and Activity B)

Activity A is singleTask and Activity B has standard launch mode.

When application started with Activity A and launch mode is singleTask, now from activity A start new activity B on button click.

So Stack is Activity A, B

Now wanted to reorder Activity A which is single task from Activity B but it's finishing Activity B first and then create new Activity A.

So stack at the momemnt is only Activity A.

What I've tried from Activity B.

val intent = Intent(this, ActivityA::class.java)
intent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
startActivity(intent)

Problem: Without finishing Activity B required to reorder Activity A with launch mode singleTask.

Appreciated in advance.

Vishal Patoliya ツ
  • 3,170
  • 4
  • 24
  • 45
  • Your use of `singleTask` launch mode is causing more problems than it solves. Explain why you need to use `singleTask` launch mode. This special launch mode is usually a very bad idea. – David Wasser Mar 18 '22 at 15:59

1 Answers1

0

You cannot reorder an Activity with singleTask launch mode to the front of the stack. An Activitywith singleTask launch mode is by definition the root Activity in a task.

Why would you want to do this? If you've configured the Activity as singleTask, you have told Android that you want this Activity to be launched as the root of a task. Why would you want to reorder this Activity to the front of the task? If the Activity can exist in the task somewhere other than the root, you shouldn't define it as singleTask!

David Wasser
  • 93,459
  • 16
  • 209
  • 274