Get the App
SLTechnology News&Howtos  ›  Development  › 

Is Activity an example of SubActivity?

Shulou Source: shulou.com Published: 2022-06-02 06:08:12 10月04日 Update

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!

Tags: Instance task content end learning practical deeper interest function variable practicality reality situation location simple operation method more friends website sentence Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information macOS Shulou Tech Info OPPO Reno