2
4

1 回答 1

2

You can't. And you shouldn't. The reason it was working before is that taskAffinity was trumping (overriding) the launchMode. Obviously they have changed/fixed that in Android 11.

If an Activity is declared as singleTask then this tells Android that the Activity wants to be the root Activity in its own task. When you launch this Activity, it should be launched in a new task, not into the same task as the Activity doing the launching.

In earlier versions of Android, the Activity would be launched into the same task if the Activity had the sametaskAffinity as the root Activity of the launching task. This was never clearly documented, and so it wasn't clear if this was a "bug" or a "feature". It looks like they have finally changed/fixed this in Android 11.

See my answers to these related questions:

于 2020-11-10T13:52:58.113 回答