开发者

Android History creating new Activity and not from Stack

开发者 https://www.devze.com 2023-02-15 13:06 出处:网络
For example, consider a task consisting of four activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of ac开发者_Python百科tivity B, then B will be brought

For example, consider a task consisting of four activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of ac开发者_Python百科tivity B, then B will be brought to the front of the history stack, with this resulting order: A, C, D, B. But my requirement is the resulting order should be A, B, C, D, B. How to achieve this?


This answer will definitely help you. (Also possible dupe ?)

  • You probably have to remove the android:launchMode attribute


I might be wrong, but by setting activity param android:launchMode="singleTask" you'll achieve what you need.

<activity android:name=".YourActivity" ... android:launchMode="singleTask"/>

With this variant only one instance of activity will ever be created, so be careful.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号