Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use flag_activity_new_task

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use flag_activity_new_task, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The FLAG_ACTIVITY_NEW_TASK comparison standard explains that it will first find out whether there is a task stack with the same affinity as the started Activity (i.e. taskAffinity, note that the activity in the same application has the same affinity). If so, move the stack as a whole to the foreground and keep the order of the old activity in the stack unchanged, and then the started Activity will be pushed into the stack. If not, a new stack will be built to store the started activity. Note that by default all Activity in the same application have the same taskAffinity.

How's FLAG_ACTIVITY_NEW_TASK?

First of all, I would like to emphasize that the following two LaunchMode startup mode functions have been distinguished:

When an Activity is set to singletask

(1) it does not create a new task stack (TaskId is all the same)

(2) if it already exists in the stack, the onNewIntent method of this instance will be called when the Activity is triggered again, and the new instance will not be recreated.

(3) if there is another Activity on the task stack where this class is located, then all the Activity on it will be out of stack.

When an Activity is set to singleinstance

(1) if there is no instance of this Activity, it creates a new task stack. (the two TaskId are different)

(2) if this instance already exists in the task stack, the onNewIntent method will be called, and no new task stack and instance will be created.

(3) become an independent Taskstack, and have and only you. And always keep an instance off the stack, return the current task first, and then another task

FLAG_ACTIVITY_NEW_TASK personally understands:

By default, all Activity in the same application have the same taskAffinity, that is, the new Activity opened by FLAG_ACTIVITY_NEW_TASK is also in the same task stack (the same task stack as Application). If you want the new Activity to enter a different stack, you need to configure as follows:

/ / pay attention to taskAffinity here

And in this OtherTaskActivityXXX page, if you open any other pages, then all other pages will be pushed into the new task stack.

Thank you for reading this article carefully. I hope the article "how to use flag_activity_new_task" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report