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

Is Activity an example of SubActivity?

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "is Activity an example of SubActivity?" interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "is Activity an example of SubActivity?"

It routinely checks the Activity at the top of the current task

Whether it is an instance of the Activity that is about to be launched

If not, in some cases, it does nothing and ends the function call.

Here, the Activity at the top of the current task is MainActivity, which is not an instance of SubActivity, so proceed to:

[java] view plaincopy boolean newTask = false; / / Should this be considered a new task? If (r.resultTo = = null & &! addingToTask & & (launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK)! = 0) {. } else if (sourceRecord! = null) {if (! addingToTask & & (launchFlags&Intent.FLAG_ACTIVITY_CLEAR_TOP)! = 0) {. } else if (! addingToTask & (launchFlags&Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)! = 0) {. } / / An existing activity is starting this new activity, so we want / / to keep the new one in the same task as the one that is starting / / it. R.task = sourceRecord.task;. } else {. }

Here, first initialize the newTask variable to false, which means that you should not start the SubActivity in the new task. Since the previous one has set addingToTask to true, the middle else if statement will be executed here, that is, r.task will be set to sourceRecord.task, that is, SubActivity will be started in the task where MainActivity is located.

At this point, I believe you have a deeper understanding of "is Activity an example of SubActivity?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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