In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the characteristics of Android application component Activity". In daily operation, I believe many people have doubts about the characteristics of Android application component Activity. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what are the characteristics of Android application component Activity?" Next, please follow the editor to study!
Notice that here we set the value of the taskAffinity property of MainActivity to "shy.luo.task.main.activity"
Set the taskAffinity property value of SubActivity to "shy.luo.task.sub.activity".
Recompile the program and run the application again on the simulator
Use the "adb shell dumpsys activity" command to take another look at the tasks that the system is running, and you will see:
[html] view plaincopyRunning activities (most recent first): TaskRecord {4069c020 # 4 A shy.luo.task.sub.activity} Run # 2: HistoryRecord {40725040 shy.luo.task/.SubActivity} TaskRecord {40695220 # 3 A shy.luo.task.main.activity} Run # 1: HistoryRecord {406b26b8 shy.luo.task/.MainActivity} TaskRecord {40599c90 # 2 A com.android.launcher} Run # 0: HistoryRecord {40646628 com.android.launcher/com.android.launcher2.Launcher}
As you can see here, SubActivity and MainActivity are running in different tasks.
The characteristics of Activity with "singleTask" startup mode set:
1. Activity with "singleTask" startup mode is set. When it starts, it will first look for the existence of a task in the system where the attribute value affinity is equal to its attribute value taskAffinity; if there is such a task, it will start in this task, otherwise it will start in the new task. Therefore, if we want Activity with "singleTask" startup mode set to start in a new task, we need to set a separate taskAffinity property value for it.
two。 If Activity with "singleTask" startup mode is not started in a new task, it will check in the existing task to see if the corresponding Activity instance already exists, and if so, it will end all the Activity on the Activity instance, that is, the Activity instance will eventually be on the top of the stack of the task.
At this point, the study on "what are the characteristics of Android application component Activity" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.