In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what are the startup modes of Activity in Android. It is very detailed and has a certain reference value. Interested friends must finish reading it!
Startup mode of Activity
Standard: each time Activity is activated (startActivity), an instance of Activity is created and placed on the task stack
SingleTop: if an Activity activates itself, that is, the Activity is at the top of the task stack, you do not need to create it. In other cases, you need to create an Activity instance.
SingleTask: if the Activity you want to activate has this instance in the task stack, you don't need to create it, just put the Activity at the top of the stack, that is, pop all the Activity instances above the Activity and call its onNewIntent.
SingleInstance: a MainActivity instance has been created in the task stack of App 1. If App 2 also wants to activate MainActivity, there is no need to create it. The two applications share the Activity instance.
4. The value passed between Activity and Fragment
Through findFragmentByTag or getActivity to get each other's reference (strong turn), and then call each other's public method, but to do so is to introduce a "strong turn" of the ugly code, the other two classes hold each other's strong reference, the coupling is large, easy to cause memory leaks.
Pass the value through the method of Bundle, such as the following code:
/ / set some parameters fragment.setArguments (bundle) for fragment in Activity; / / get the method Bundle arguments = getArguments () in Activity through getArguments in fragment
3. Using eventbus for communication, this method has high real-time performance, and the Activity and Fragment can be completely decoupled.
The code in / / Activity is EventBus.getDefault (). Post ("message"); / / the code in Fragment is EventBus.getDefault (). Register (this); @ Subscribe public void test (String text) {tv_test.setText (text);} above is all the content of the article "what are the startup modes of Activity in Android". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.