A starting method and device, terminal equipment and medium
By merging MainActivity and SplashActivity and utilizing class name and intent information settings, the problem of slow startup caused by the increase of splash screen pages was solved, achieving the effects of fast startup and avoiding multiple instances.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2022-03-01
- Publication Date
- 2026-07-07
Smart Images

Figure CN116737251B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a startup method, apparatus, terminal device, and medium. Background Technology
[0002] Currently, most Android applications add a splash screen (MainActivity) before the main activity to ensure that only one main activity exists throughout the entire usage process, and to allow users to return to the previous activity by clicking the corresponding app icon after switching to the current activity by pressing the home button. However, adding a splash screen lengthens the application startup process, thus affecting startup speed. Summary of the Invention
[0003] This disclosure provides a startup method, apparatus, terminal device, and medium to improve the startup speed of applications.
[0004] In a first aspect, embodiments of this disclosure provide a startup method, including:
[0005] Method to start a newly created activity component;
[0006] When executing the method to create a new activity component, determine whether the activity component to be created is a homepage activity component;
[0007] When executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the activity component to be created will be set to an empty activity component by setting the corresponding class name.
[0008] The empty activity component is closed, and the first splash screen activity component is launched by adding a label. The first intent information of adding a label indicates that an existing homepage activity component is launched and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
[0009] Secondly, embodiments of this disclosure also provide a starting device, comprising:
[0010] The startup module is used to launch the method for creating a new active component;
[0011] The determination module is used to determine whether the activity component to be created is a homepage activity component when the new activity component method is executed;
[0012] The settings module is used to, when executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, set the corresponding class name to point the activity component to be created to an empty activity component.
[0013] The closing module is used to close the empty activity component and start the first splash screen activity component by adding a first intent information of the label. The first intent information of the label indicates that the existing homepage activity component is started and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
[0014] Thirdly, embodiments of this disclosure also provide a terminal device, including:
[0015] One or more processing devices;
[0016] Storage device for storing one or more programs;
[0017] The one or more programs are executed by the one or more processing devices, causing the one or more processing devices to implement the startup method provided in the embodiments of this disclosure.
[0018] Fourthly, embodiments of this disclosure also provide a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the startup method provided in embodiments of this disclosure.
[0019] This disclosure provides a startup method, apparatus, terminal device, and medium. First, a method for creating a new activity component is initiated. During the execution of this method, it is determined whether the activity component to be created is a homepage activity component. Then, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the corresponding class name is set to point the current activity component to an empty activity component. Finally, the empty activity component is closed, and a first splash screen activity component is launched by adding a first intent information tag. The first intent information tag indicates that an existing homepage activity component should be launched and that any activity component created after the existing homepage activity component should be deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component. This method, when a homepage activity component already exists, directs the currently created activity component to an empty activity component and closes that empty activity component. It also launches a first splash screen activity component using the first intent information of the added tag. This approach launches an existing homepage activity component while avoiding the launch of a new one, and also prevents the simultaneous existence of multiple homepage activity component instances. Furthermore, by launching the first splash screen activity component using the first intent information, whose target activity component attribute is the homepage activity component, the method effectively merges the first splash screen activity component and the homepage activity component, thereby improving launch speed. Attached Figure Description
[0020] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0021] Figure 1 This is a flowchart illustrating a startup method provided in Embodiment 1 of this disclosure;
[0022] Figure 2 This is a flowchart illustrating a startup method provided in Embodiment 2 of this disclosure;
[0023] Figure 3 This is a schematic diagram illustrating the implementation of a startup method without changing the startup mode, as provided in Embodiment 2 of the present invention.
[0024] Figure 4 This is a schematic diagram illustrating the implementation of a startup method for modifying the Component information of the MainActivity Intent according to Embodiment 2 of the present invention;
[0025] Figure 5 This is a schematic diagram illustrating the implementation of creating an Activity according to Embodiment 2 of the present invention;
[0026] Figure 6 This is a schematic diagram illustrating the implementation of a startup method provided in Embodiment 2 of the present invention;
[0027] Figure 7 This is a schematic diagram of the structure of a starting device provided in Embodiment 3 of this disclosure;
[0028] Figure 8 This is a schematic diagram of the structure of a terminal device provided in Embodiment 4 of this disclosure. Detailed Implementation
[0029] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0030] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0031] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0032] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0033] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0034] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0035] In the following embodiments, each embodiment provides optional features and examples. The various features described in the embodiments can be combined to form multiple optional solutions. Each numbered embodiment should not be regarded as only one technical solution. Furthermore, unless otherwise specified, the embodiments and features in the embodiments of this disclosure can be combined with each other.
[0036] Example 1
[0037] Figure 1 This is a flowchart illustrating a startup method provided in Embodiment 1 of this disclosure. This method is applicable to improving application startup speed. The method can be executed by a startup device, which can be implemented by software and / or hardware and is generally integrated into a terminal device. In this embodiment, the terminal device includes, but is not limited to, devices such as computers, laptops, smartphones, and tablets.
[0038] In this embodiment, MainActivity and SplashActivity can be merged into a single activity component to shorten the application's startup chain and thus improve startup speed. After merging MainActivity and SplashActivity, multiple instances of MainActivity may occur when MainActivity is launched from outside the current application. This embodiment proposes a startup method to solve the problem of multiple instances of MainActivity being launched from outside the application. Launching from outside the application can be understood as the process of launching this application from another application that is not this application.
[0039] like Figure 1 As shown in Embodiment 1 of this disclosure, a startup method includes the following steps:
[0040] S110. Start the method to create a new activity component. When executing the method to create a new activity component, determine whether the activity component to be created is a homepage activity component.
[0041] In this embodiment, the activity component is one of the four basic components in the Android system and can be represented by Activity; Activity can be considered as a component that can be used to interact with the user. The method to create a new activity component can be represented by newActivity. The method to create a new activity component can refer to a series of methods defined in the new activity component that need to be overridden to implement the functionality of the new activity component. The activity component to be created can refer to the activity component that is currently waiting to be created. The home activity component can refer to the activity component used to display the main page when the application starts, and can be represented as MainActivity.
[0042] Optionally, the launch mode of the homepage activity component is the top stack mode.
[0043] In Android systems, the launch mode of an activity component can be considered an attribute setting that characterizes the strategy for launching the activity component. This can include standard mode, singleTop mode, singleTask mode, and singleInstance mode. In this embodiment, the launch mode of the homepage activity component can be set to singleTop mode. Each application has a task stack, which can be considered a stack for managing and storing activity components. The working principle of singleTop mode is that when an activity component is launched, if it is found that the activity component is at the top of the task stack, it can be used directly without creating a new activity component instance; otherwise, a new activity component instance needs to be created. By setting the launch mode of the homepage activity component to singleTop mode, when switching out of the application's secondary page using the Home button and then clicking the corresponding icon to enter the application again, it is guaranteed that you will return to the previous secondary page. Second-level pages can be considered as pages displayed by clicking on various function links within the application's homepage. In other words, all pages opened within the application other than the homepage can be considered as second-level pages.
[0044] Optional, methods for creating new activity components include: methods for creating new activity components in custom test framework classes.
[0045] In this context, for each application, a test framework can be considered a framework available for all lifecycle calls of the application and its active components, represented as an Instrumentaion. A custom test framework class (i.e., a custom test framework class) can be implemented by inheriting from the test framework (i.e., Instrumentaion) in the application. Specifically, in an application, each process can have a corresponding active thread (i.e., ActivityThread), and each active thread can have a corresponding test framework object. Reflection can be used to obtain the test framework object in the active thread, and this test framework object can be used as a parameter to create a custom test framework object. Based on this, reflection can be used to replace the original test framework object of the active thread with the custom test framework object; this custom test framework object is the custom test framework class. A process can be understood as a running program with independent functionality within an application, and is the basic unit for resource allocation and scheduling. An application can include multiple processes to perform tasks with different functions. A thread can be the smallest unit of computation that the operating system can schedule; it is contained within a process and is the actual unit of operation within the process. A process can include multiple threads. Reflection can be understood as a reflection mechanism, which can refer to a mechanism that can dynamically obtain information about objects or classes in an application, as well as the methods and properties of those objects or classes, at runtime.
[0046] The application's test framework can include a series of methods that implement corresponding functions, and all the methods contained within the custom test framework class can be overridden using a proxy forwarding method. Based on this, the method for creating a new activity component in this embodiment can include the method for creating a new activity component of the custom test framework class.
[0047] Optionally, methods for creating new active components include: methods for creating new active components that instantiate active components using the application component factory class.
[0048] The instantiation of an activity component by the application component factory class can be considered as creating an instantiated object based on the application component factory class. The application component factory class can be considered a factory class provided by the Android system to which the application belongs, enabling a hook mechanism. The hook mechanism refers to the ability to integrate its own code into the process of the hooked application to achieve control over that process. The instantiation of an activity component by the application component factory class can be represented as `AppComponentFactory instantiateActivity`.
[0049] When the Android system version is too high, the application component factory class can be used to instantiate the activity component to replace the custom test framework class. That is, the method to create a new activity component can include the method to create a new activity component by instantiating the activity component from the application component factory class.
[0050] In this embodiment, the method for creating a new activity component is initiated. When executing this method, it can be determined whether the activity component to be created is a homepage activity component. No limitations are made here regarding how the method for creating a new activity component is initiated or how it is determined whether the activity component to be created is a homepage activity component.
[0051] S120. When executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, then the activity component to be created is set to an empty activity component by setting the corresponding class name.
[0052] In this embodiment, if it is determined during the execution of the "Create New Activity Component" method that the activity component to be created is a homepage activity component, and a homepage activity component already exists, then the activity component to be created can be set to an empty activity component by setting its class name. The class name can be considered a parameter used to add the data type attribute of the activity component, such as the `classname` parameter. Setting the activity component to an empty activity component can be considered as creating the activity component to be created as an activity component with empty content.
[0053] This does not specify how to determine whether the homepage activity component currently exists.
[0054] Optionally, when executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, then the activity component to be created is set to an empty activity component by setting the corresponding class name. This includes: when executing the method to create a new activity component, if the activity component to be created is a homepage activity component, then the existence of a homepage activity component is determined by the creation and destruction information of the homepage activity component; if a homepage activity component already exists, then the activity component to be created is set to an empty activity component by setting the corresponding class name.
[0055] Each activity component has its own execution lifecycle, which can include the creation, startup, visibility, pause, stop, and destruction of the activity component. The creation and destruction of the activity component are interdependent, as are startup and stop, and visibility and pause.
[0056] The creation and destruction of activity components can be achieved using appropriate methods, such as executing the `onCreate` and `onDestroy` methods respectively. The creation information for a homepage activity component refers to the information about its creation via the `onCreate` method; the destruction information refers to the information about its destruction via the `onDestroy` method.
[0057] In this embodiment, the existence of a homepage activity component can be determined by its creation and destruction information. For example, based on the creation and destruction information, if the number of created homepage activity components is greater than the number of destroyed components, it indicates that there are currently undestroyed homepage activity components, thus confirming the existence of a homepage activity component. If the number of created homepage activity components equals the number of destroyed components, it indicates that there are currently no undestroyed homepage activity components, thus confirming the absence of a homepage activity component. It is understandable that the creation and destruction of homepage activity components are relative; the creation of a homepage activity component precedes its subsequent destruction. However, it should be noted that this creation and destruction process is irreversible; destruction cannot occur without creation. Therefore, the situation where the number of created homepage activity components is less than the number of destroyed components is not possible.
[0058] When executing the method to create a new activity component, if the activity component to be created is determined to be a homepage activity component, and if a homepage activity component already exists, the activity component to be created can be set to an empty activity component by setting the corresponding class name.
[0059] S130. Close the empty activity component and start the first splash screen activity component by adding a label. The first intention information of adding a label indicates that the existing homepage activity component is started and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
[0060] In this embodiment, after setting the corresponding class name to point the currently created activity component to the empty activity component, the empty activity component can be closed. For example, the empty activity component can be closed during the onCreate process of the empty activity component.
[0061] The primary intent information for adding tags can be considered as the external intent information used by the application to launch the homepage activity component, which includes the "Launch Activity Component" tag and the "Clear Top Activity Component" tag. The intent information (i.e., Intent) can refer to the data carrier used for data transfer between applications or between components of applications. The "Launch Activity Component" tag, represented as FLAG_ACTIVITY_NEW_TASK, can refer to a tag used to launch the activity component in a new task (i.e., NEW_TASK). The "Clear Top Activity Component" tag, represented as FLAG_ACTIVITY_CLEAR_TOP, can refer to a tag used to clear all activity components above the current activity component within the same TASK. A TASK can be considered a stack for storing multiple activity components, with each level storing one activity component. The stack operates on a Last-In-First-Out (LIFO) principle; therefore, all activity components above the current activity component can be considered as other activity components created after the current activity component.
[0062] In this embodiment, the first intent information of adding the FLAG_ACTIVITY_NEW_TASK tag can be used to instruct the activation of an existing homepage activity component. Furthermore, adding the first intent information of the FLAG_ACTIVITY_CLEAR_TOP tag can be used to instruct the deletion of activity components created after the existing homepage activity component. The working principle of the singleTask mode is that when activating the corresponding activity component, if the activity component does not exist, a new instance can be created in the current TASK; if the activity component exists, all activity components above it in the current TASK can be cleared. This embodiment achieves a feature similar to the singleTask mode of clearing all activity components (i.e., CLEAR_TOP) above the current activity component in the TASK by adding the first intent information of the FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP tags.
[0063] The first splash screen activity component can refer to the splash screen activity component in the stack where the activity component to be created currently resides; the splash screen activity component can be an activity component used to display the splash screen page when the application starts, and can be represented as SplashActivity. The first splash screen activity component is launched, where the target activity component attribute of the first splash screen activity component is the home activity component. The target activity component attribute can refer to the actual nature of the activity component. The fact that the target activity component attribute of the first splash screen activity component is the home activity component can be understood as meaning that each time the first splash screen activity component is launched, it can be transformed into launching the home activity component.
[0064] In this embodiment, the target activity component attribute of the first splash screen activity component can be set to the home activity component by combining the activity component alias identifier and the corresponding target activity component attribute (i.e., activity-alias + targetActivity). The activity component alias identifier can refer to an alias of an existing activity component, and its corresponding target activity component attribute can be used to specify the corresponding target activity component based on the activity component alias identifier. After merging MainActivity and SplashActivity, SplashActivity will no longer exist. This embodiment, by setting the target activity component attribute of the first splash screen activity component to the home activity component, ensures that launching any first splash screen activity component will result in launching the home activity component. This avoids the situation that occurs after merging MainActivity and SplashActivity, where launching via the SplashActivity name fails to find the SplashActivity.
[0065] Optionally, the first splash screen activity component may be initiated via component information indicated by the first intent information.
[0066] The component information (i.e., Component information) can be understood as containing the class name information of the target component passed by the specified Intent. In other words, the target component specified in the Component information can be directly used and launched. Instructing the launch of the first splash screen activity component through the component information of the first intent information can be achieved by modifying the component information of the first intent information, changing it from pointing to the home page activity component to pointing to the first splash screen component.
[0067] In one embodiment, when executing the method to create a new activity component, it is determined whether the activity component to be created is a homepage activity component. If the activity component to be created is not a homepage activity component, or if there is no homepage activity component, the original implementation can be called. Calling the original implementation can be understood as calling the corresponding original method in the method to create the new activity component to start the activity component to be created.
[0068] The first embodiment of this disclosure provides a startup method. First, a method for creating a new activity component is started. When the method for creating a new activity component is executed, it is determined whether the activity component to be created is a homepage activity component. Then, when the method for creating a new activity component is executed, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the activity component to be created is set to an empty activity component by setting the corresponding class name. Finally, the empty activity component is closed, and a first splash screen activity component is started by adding a first intent information of a tag. The first intent information of the tag indicates that an existing homepage activity component is started and that an activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component. This method, when a homepage activity component already exists, directs the currently to-be-created activity component to an empty activity component and closes that empty activity component. It also launches a first splash screen activity component using the first intent information of the added tag. This launches an existing homepage activity component while avoiding the launch of a new one, and also prevents the simultaneous existence of multiple homepage activity component instances. Furthermore, by launching the first splash screen activity component using the first intent information, and setting its target activity component attribute to the homepage activity component, this method effectively merges the first splash screen activity component and the homepage activity component, thereby improving launch speed.
[0069] Optionally, it also includes: a launch activity component method of the launch context; when launching the homepage activity component using the launch activity component method of the execution context, launching a second splash screen activity component by adding a second intent information of a tag, wherein the second intent information of the tag indicates launching an existing homepage activity component and deleting the activity component created after the existing homepage activity component, and the target activity component attribute of the second splash screen activity component is the homepage activity component.
[0070] After merging MainActivity and SplashActivity, launching MainActivity within the current application may still result in multiple instances of MainActivity. Launching MainActivity within the application means launching the corresponding MainActivity within the current application itself. In this embodiment, the issue of launching multiple instances of MainActivity internally can be resolved by using the "Launch Activity Component" method of the launch context. When launching the home activity component, the second splash screen activity component is launched using the second intent information with added tags.
[0071] Here, "context" can refer to global information representing the application environment of an activity component. "Start Activity Component Method" refers to the method existing in the Context used to start an activity component; this method can be represented as the `startActivity` method. "Added Tag Second Intent Information" refers to the application's internal intent information for launching the home activity component, which includes the "Start Activity Component" tag (i.e., the `FLAG_ACTIVITY_NEW_TASK` tag) and the "Clear Top Activity Component" tag (i.e., the `FLAG_ACTIVITY_CLEAR_TOP` tag). "Second Splash Screen Activity Component" refers to the splash screen activity component currently awaiting launch after the internal `MainActivity` is started.
[0072] Adding the FLAG_ACTIVITY_NEW_TASK tag as a secondary intent can instruct the launch of an existing homepage activity component. Adding the FLAG_ACTIVITY_CLEAR_TOP tag as a secondary intent can instruct the deletion of any activity component created after the existing homepage activity component. The target activity component attribute of the second splash screen activity component can be set to the homepage activity component using activity-alias + targetActivity.
[0073] Building upon the above embodiments, regarding launching MainActivity from outside the application, since the context's launch activity component method (i.e., context.startactivity) cannot be controlled when launching MainActivity from outside the application, newActivity needs to be launched regardless of whether a MainActivity instance already exists. Furthermore, if a MainActivity instance already exists, when executing newActivity, the operation of setting the corresponding class name to point the currently to-be-created activity component to an empty activity component can be performed; if a MainActivity instance does not exist, MainActivity can be launched normally.
[0074] For launching MainActivity within the application, you can control the corresponding context.startActivity. Based on this, if the current launch is MainActivity and a MainActivity instance already exists, there's no need to launch newActivity, because the system has already opened MainActivity and handled the corresponding actions at context.startActivity. If the current launch is MainActivity and a MainActivity instance doesn't exist, you can launch newActivity. However, it should be noted that since a MainActivity instance doesn't exist, it needs to be created. Therefore, when launching newActivity, there's no need to point it to an empty Activity; you can launch it directly.
[0075] Example 2
[0076] Figure 2 This is a flowchart illustrating a startup method provided in Embodiment 2 of this disclosure. Embodiment 2 is a specific embodiment based on the various optional solutions in the above embodiments. In this embodiment, the process of determining whether a homepage activity component exists is described in detail. For details not covered in this embodiment, please refer to Embodiment 1.
[0077] like Figure 2 As shown in Embodiment 2 of this disclosure, a startup method includes the following steps:
[0078] S210. Start the method to create a new activity component. When executing the method to create a new activity component, determine whether the activity component to be created is a homepage activity component.
[0079] In this embodiment, the method for creating a new activity component is initiated, and it can be determined whether the activity component to be created is a homepage activity component within the new activity component method of the custom test framework class. When the Android system version is too high, it can be determined whether the activity component to be created is a homepage activity component within the new activity component method that instantiates the activity component in the application component factory class.
[0080] The launch mode of the homepage activity component can be set to top stack mode.
[0081] S220. When executing the method to create a new activity component, if the activity component to be created is a homepage activity component, the existence of a homepage activity component is determined by the creation and destruction information of the homepage activity component.
[0082] In this embodiment, when executing the method to create a new activity component, if the activity component to be created is a homepage activity component, the existence of a homepage activity component can be determined by comparing the number of homepage activity components created and destroyed based on the creation and destruction information of the homepage activity component.
[0083] S230. If a homepage activity component already exists, the current activity component to be created will be set to an empty activity component by setting the corresponding class name.
[0084] In this embodiment, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the activity component to be created can be set to an empty activity component by setting the corresponding class name.
[0085] S240, Close the empty activity component and start the first splash screen activity component by adding the first intent information of the label.
[0086] In this embodiment, the first intent information for adding the tag can instruct the activation of an existing homepage activity component and the deletion of an activity component created after the existing homepage activity component. The target activity component attribute of the first splash screen activity component can be set to the homepage activity component.
[0087] The empty activity component is closed, and the component information can be used to indicate the start of the first splash screen activity component by adding the first intent information of the label.
[0088] The second embodiment of this disclosure provides a startup method that specifies the process of determining whether a homepage activity component currently exists. This method can determine the existence of a homepage activity component by using its creation and destruction information. If a homepage activity component already exists, the method points the currently to-be-created activity component (identified as a homepage activity component) to an empty activity component and closes the empty activity component. Furthermore, it starts a first splash screen activity component using first intent information with added tags. Starting an existing homepage activity component avoids starting a new one and also prevents the simultaneous existence of multiple homepage activity component instances. In addition, starting the first splash screen activity component using first intent information, where the target activity component attribute of the first splash screen activity component is the homepage activity component, effectively merges the first splash screen activity component and the homepage activity component, thereby improving startup speed.
[0089] The present disclosure is described by way of example below:
[0090] This embodiment merges SplashActivity and MainActivity into a single Activity, eliminating SplashActivity to shorten the startup chain and improve startup speed, while also addressing the following three technical issues:
[0091] 1) The issue of failure to navigate to SplashActivity after removing it;
[0092] 2) The problem that after removing SplashActivity, pressing the home button to switch out and then clicking the icon to return does not return to the previous page;
[0093] 3) The issue of not being able to guarantee that there is only one MainActivity;
[0094] This embodiment proposes a startup method to solve the above problems. The specific implementation process of this method is as follows:
[0095] First, resolve the issue of failure to navigate to SplashActivity:
[0096] After merging SplashActivity and MainActivity, SplashActivity will no longer exist. In some cases where the SplashActivity is launched by name, the SplashActivity will not be found. To address this, this embodiment can use activity-alias + targetActivity to point SplashActivity to MainActivity. In this way, any launch of SplashActivity will be converted to launch MainActivity.
[0097] Then, resolve the issue of not being able to return to the previous page after switching out via the Home button:
[0098] Before merging SplashActivity and MainActivity, their LaunchModes were standard and singleTask, respectively. This ensured that MainActivity had only one instance, and that users could return to the previous page when navigating out of the application via the Home button and clicking the corresponding icon to re-enter. After merging SplashActivity and MainActivity, the launcher activity (the activity component used as the application's launcher) became MainActivity. If singleTask mode continued to be used, users would not be able to return to the previous secondary page when navigating out via the Home button and clicking the icon again; instead, they would be returned to the Main page (the application's home page). Therefore, after the merger, MainActivity's LaunchMode could no longer use singleTask mode; instead, singleTop mode could be used.
[0099] Figure 3 This is a schematic diagram illustrating the implementation of a startup method without changing the startup mode, as provided in Embodiment 2 of the present invention. Figure 3 As shown, the active components remain unchanged before and after switching using the Home button; they are still MainActivity, AActivity, and BActivity. AActivity and BActivity can represent secondary pages other than the home page (MainActivity). When the corresponding icon of the application is clicked again, it will not return to the previous secondary page, but will instead return to the Main page (i.e., MainActivity has been launched).
[0100] Finally, the issue of multiple MainActivities was resolved:
[0101] I. Issues with launching multiple MainActivity instances internally
[0102] While using the singleTop mode solves the problem of not being able to return to the previous page after switching out via the Home button, it introduces the issue of multiple instances of MainActivity. Applications typically contain logic related to the MainActivity's lifecycle; if multiple instances of MainActivity exist, this logic will be affected. Furthermore, implementing multiple MainActivities can lead to unnecessary resource overhead. A solution to this problem is to add the FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP tags to all Intents that launch MainActivity within the application, achieving a clear top feature similar to the singleTask mode.
[0103] The solution using FLAG_ACTIVITY_NEW_TASK + FLAG_ACTIVITY_CLEAR_TOP can basically solve the problem of multiple instances of MainActivity being launched internally. However, in actual testing, it was found that on some application systems, even with the clear top feature implemented, the problem of multiple instances of MainActivity still exists. Analysis revealed that on these systems, even if SplashActivity is pointed to MainActivity via activity-alias + targetActivity, the Activity Manager Service (AMS) still considers SplashActivity to be launched. Subsequent launches of MainActivity will assume that MainActivity did not exist previously, thus launching another MainActivity. To address this issue, the solution adopted in this disclosure is to modify the Component information of the MainActivity Intent, changing it from MainActivity to SplashActivity.
[0104] Figure 4 This is a schematic diagram illustrating the implementation of a startup method for modifying the Component information of the MainActivity Intent, as provided in Embodiment 2 of the present invention. Figure 4As shown, if the Component information of the MainActivity Intent is not modified, launching MainActivity will be interpreted by AMS as launching SplashActivity, and a new MainActivity1 will be launched. After modifying the Component information of the MainActivity Intent, launching MainActivity will change the MainActivity pointer to SplashActivity. In this case, only the existing MainActivity will be launched, and a new MainActivity will not be launched.
[0105] To minimize intrusion into business logic and prevent the issue of multiple MainActivities caused by internal startup in subsequent iterations, instrumentation was used on the Context startActivity call. For calls to start MainActivity, the original implementation is called only after adding a flag to the Intent and replacing the Component information (i.e., modifying the Component information of the MainActivity Intent). The instrumentation approach was chosen to address issues where some base Activity classes cannot be directly modified in the code.
[0106] II. Issues with launching multiple MainActivity instances externally
[0107] The above solution to the problem of multiple instances of MainActivity internally relies on modifying the Intent of the Activity to be launched before the Activity is started. This method obviously cannot solve the problem of multiple instances of MainActivity caused by launching MainActivity externally. Therefore, to address the issue of multiple instances caused by externally launched MainActivity, we can return to the starting point of solving the problem of multiple MainActivity instances. It's clear that the reason for avoiding multiple MainActivity instances is to prevent the simultaneous existence of multiple MainActivity objects, leading to unexpected execution of the MainActivity lifecycle. Therefore, as long as we ensure that multiple MainActivity objects do not exist simultaneously, the problem of multiple instances of MainActivity when launched externally can also be solved.
[0108] To avoid multiple MainActivity objects appearing simultaneously, it's first necessary to determine if a MainActivity object already exists. In this example, this can be achieved by monitoring the Activity's lifecycle and adjusting the number of MainActivity instances in its onCreate (creation information) and onDestroy (destruction information) calls. If the MainActivity instance count is 0, it's assumed that a MainActivity object (i.e., the homepage activity component) does not currently exist. (In other words, the existence of the homepage activity component can be determined by its creation and destruction information.)
[0109] After solving the problem of counting MainActivity objects, the next step is to ensure that the number of MainActivity objects that exist simultaneously is always kept below 1. Figure 5 This is a schematic diagram illustrating the implementation of creating an Activity according to Embodiment 2 of the present invention. Figure 5 The diagram illustrates an existing method flow for creating an Activity, in which this embodiment can be selected. Figure 5 The solution focuses on the timing of creating an Activity using the `newActivity` method of `Instrument`. The specific implementation is as follows:
[0110] First, inherit from Instrumentation to implement a custom Instrumentation class, and override all its methods using a proxy forwarding method;
[0111] Secondly, the Instrumentation object in ActivityThread is obtained by reflection, and a custom Instrumentation object is created with it as a parameter. The original Instrumentation in ActivityThread is replaced with the custom Instrumentation object by reflection.
[0112] Then, in the newActivity method (i.e., the method to create a new activity component) of the custom Instrumentation class (i.e., the custom test framework class), it is determined whether the Activity to be created is MainActivity. If it is not MainActivity or there is no MainActivity object, the original implementation is called; otherwise, the className parameter (i.e., the class name parameter) of the Activity to be created is replaced and pointed to an empty Activity to create an empty Activity.
[0113] Finally, in the onCreate method of this empty Activity, finish itself (i.e. close the empty Activity), and at the same time, start the SplashActivity with an Intent that adds the FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP flags (i.e. start the first splash screen activity component with the first intent information of the added tag).
[0114] On higher versions of Android systems, you can also replace the custom Instrumentation class (i.e., the method to create a new activity component, including the method to create a new activity component in AppComponentFactory instantiateActivity) with AppComponentFactorinstantiateActivity.
[0115] Figure 6 This is a schematic diagram illustrating the implementation of a startup method provided in Embodiment 2 of the present invention. Figure 6 As shown, MainActivity is started. After confirming that the current activity component to be created is MainActivity and that MainActivity already exists, the className parameter of the Activity to be created is replaced to point to an empty Activity, thus creating an empty Activity (i.e., FakeActivity in the diagram). FakeActivity is then finished, and SplashActivity is started using an Intent with the FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TOP flags (SplashActivity already points to MainActivity, meaning the target activity attribute of SplashActivity is MainActivity; this can be understood as starting MainActivity). This completes the startup of MainActivity.
[0116] Example 3
[0117] Figure 7 This is a schematic diagram of a starting device provided in Embodiment 3 of the present disclosure, wherein the device can be implemented by software and / or hardware, and is generally integrated into a terminal device.
[0118] like Figure 7 As shown, the device includes: a startup module 310, a determination module 320, a setting module 330, and a shutdown module 340;
[0119] Among them, startup module 310 is used to start the method for creating a new activity component;
[0120] The determination module 310 is used to determine whether the activity component to be created is a homepage activity component when the new activity component method is executed;
[0121] The configuration module 320 is used to set the current activity component to an empty activity component when executing the method to create a new activity component. If the activity component to be created is a homepage activity component and a homepage activity component already exists, the corresponding class name will be set to point the current activity component to be created to an empty activity component.
[0122] The closing module 330 is used to close the empty activity component and start the first splash screen activity component by adding a first intent information of a label. The first intent information of adding a label indicates that an existing homepage activity component is started and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
[0123] In this embodiment, the device first starts module 310 to initiate the method for creating a new activity component; then, through determination module 320, it determines in the method for creating a new activity component whether the activity component to be created is a homepage activity component; then, through setting module 330, when executing the method for creating a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the corresponding class name is set to point the activity component to an empty activity component; finally, through closing module 340, the empty activity component is closed, and the first splash screen activity component is started through the first intent information of adding a tag. The first intent information of adding a tag indicates that an existing homepage activity component is started and that an activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component. This device, when a homepage activity component already exists, directs the currently to-be-created activity component to an empty activity component and closes that empty activity component. It also launches a first splash screen activity component using the first intent information of the added tag. This approach launches an existing homepage activity component while avoiding the launch of a new one, and also prevents the simultaneous existence of multiple homepage activity component instances. Furthermore, by launching the first splash screen activity component using the first intent information, with the target activity component attribute being the homepage activity component, it effectively merges the first splash screen activity component and the homepage activity component, thereby improving launch speed.
[0124] Optionally, the launch mode of the homepage activity component is the top stack mode.
[0125] Optionally, the method for creating a new activity component includes:
[0126] The method for creating a new activity component in a custom test framework class.
[0127] Optionally, the method for creating a new activity component includes:
[0128] The application component factory class instantiates the method for creating a new active component.
[0129] Optionally, when executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, then the activity component to be created is set to an empty activity component by setting the corresponding class name, including:
[0130] When executing the method for creating a new activity component, if the activity component to be created is a homepage activity component, the existence of a homepage activity component is determined by the creation and destruction information of the homepage activity component.
[0131] If a homepage activity component already exists, the current activity component to be created will be set to an empty activity component by setting the corresponding class name.
[0132] Optionally, the device further includes:
[0133] The method to launch the active component in the launch context;
[0134] When the launch activity component method of the context is executed to launch the homepage activity component, the second splash screen activity component is launched by adding a second intent information of a tag. The second intent information of the tag indicates that the existing homepage activity component is launched and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the second splash screen activity component is the homepage activity component.
[0135] Optionally, the first splash screen activity component may be initiated via component information indicated by the first intent information.
[0136] The above-described starting device can execute the starting method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the method.
[0137] Example 4
[0138] Figure 8 This is a schematic diagram of the structure of a terminal device provided in Embodiment 4 of this disclosure. Figure 8A schematic diagram of a terminal device 400 suitable for implementing embodiments of the present disclosure is shown. The terminal device 400 in embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The terminal device 400 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0139] like Figure 8 As shown, the terminal device 400 may include one or more processing devices (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 402 or a program loaded from storage device 408 into random access memory (RAM) 403. One or more processing devices 401 implement the methods provided in this disclosure. Various programs and data required for the operation of the electronic device 400 are also stored in RAM 403. The processing devices 401, ROM 402, and RAM 403 are interconnected via bus 404. An input / output (I / O) interface 405 is also connected to bus 404.
[0140] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 408 including, for example, magnetic tapes, hard disks, etc., for storing one or more programs; and communication devices 409. Communication device 409 allows terminal device 400 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 A terminal device 400 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0141] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 409, or installed from a storage device 408, or installed from a ROM 402. When the computer program is executed by a processing device 401, it performs the functions defined in the methods of embodiments of this disclosure.
[0142] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0143] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol, such as Hypertext Transfer Protocol (HTTP), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (LANs), wide area networks (WANs), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0144] The aforementioned computer-readable medium may be included in the aforementioned terminal device 400; or it may exist independently and not assembled into the terminal device 400.
[0145] The aforementioned computer-readable medium stores one or more computer programs that, when executed by a processing device, implement the following method: the computer-readable medium carries one or more programs that, when executed by the electronic device, cause the terminal device 400 to: write computer program code for performing the operations of this disclosure in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0146] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. Each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0147] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules are not, in some cases, intended to limit the functionality of the module itself.
[0148] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Parts (ASSP), System on Chip (SOC), Complex Programming Logic Device (CPLD), and so on.
[0149] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0150] According to one or more embodiments of this disclosure, Example 1 provides a startup method, including:
[0151] Method to start a newly created activity component;
[0152] When executing the method to create a new activity component, determine whether the activity component to be created is a homepage activity component;
[0153] When executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the activity component to be created will be set to an empty activity component by setting the corresponding class name.
[0154] The empty activity component is closed, and the first splash screen activity component is launched by adding a label. The first intent information of adding a label indicates that an existing homepage activity component is launched and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
[0155] According to one or more embodiments of this disclosure, Example 2 describes the method described in Example 1.
[0156] The launch mode for the homepage activity component is the top-of-stack mode.
[0157] According to one or more embodiments of this disclosure, Example 3 describes the method described in Example 1.
[0158] The method for creating a new activity component includes:
[0159] The method for creating a new activity component in a custom test framework class.
[0160] According to one or more embodiments of this disclosure, Example 4 describes the method described in Example 1.
[0161] The method for creating a new activity component includes:
[0162] The application component factory class instantiates the method for creating a new active component.
[0163] According to one or more embodiments of this disclosure, Example 5 describes the method described in Example 1.
[0164] When executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, then the activity component to be created is set to an empty activity component by setting the corresponding class name, including:
[0165] When executing the method for creating a new activity component, if the activity component to be created is a homepage activity component, the existence of a homepage activity component is determined by the creation and destruction information of the homepage activity component.
[0166] If a homepage activity component already exists, the current activity component to be created will be set to an empty activity component by setting the corresponding class name.
[0167] According to one or more embodiments of this disclosure, Example 6 describes the method described in Example 1.
[0168] Also includes:
[0169] The method to launch the active component in the launch context;
[0170] When the launch activity component method of the context is executed to launch the homepage activity component, the second splash screen activity component is launched by adding a second intent information of a tag. The second intent information of the tag indicates that the existing homepage activity component is launched and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the second splash screen activity component is the homepage activity component.
[0171] According to one or more embodiments of this disclosure, Example 7 describes the method described in Example 1.
[0172] The first splash screen activity component is initiated by the component information instruction of the first intent information.
[0173] According to one or more embodiments of this disclosure, Example 8 provides a starting device, including:
[0174] The startup module is used to launch the method for creating a new active component;
[0175] The determination module is used to determine whether the activity component to be created is a homepage activity component when the new activity component method is executed;
[0176] The settings module is used to set the current activity component to an empty activity component when executing the method to create a new activity component. If the activity component to be created is a homepage activity component and a homepage activity component already exists, the corresponding class name will be set to the empty activity component.
[0177] The closing module is used to close the empty activity component and start the first splash screen activity component by adding a first intent information of the label. The first intent information of the label indicates that the existing homepage activity component is started and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
[0178] According to one or more embodiments of this disclosure, Example 9 provides a terminal device, including:
[0179] One or more processing devices;
[0180] Storage device for storing one or more programs;
[0181] When the one or more programs are executed by the one or more processing devices, the one or more processing devices perform the method as described in any of Examples 1-7.
[0182] According to one or more embodiments of the present disclosure, Example 10 provides a computer-readable medium having a computer program stored thereon that, when executed by a processing device, implements the method described in any of Examples 1-7.
[0183] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0184] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0185] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A startup method, characterized in that, The method includes: Method to start a newly created activity component; When executing the method to create a new activity component, determine whether the activity component to be created is a homepage activity component; When executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, the activity component to be created will be set to an empty activity component by setting the corresponding class name. The empty activity component is closed, and the first splash screen activity component is launched by adding a label. The first intent information of adding a label indicates that an existing homepage activity component is launched and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
2. The method according to claim 1, characterized in that, The launch mode for the homepage activity component is the top-of-stack mode.
3. The method according to claim 1, characterized in that, The method for creating a new activity component includes: The method for creating a new activity component in a custom test framework class.
4. The method according to claim 1, characterized in that, The method for creating a new activity component includes: The application component factory class instantiates the method for creating a new active component.
5. The method according to claim 1, characterized in that, When executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, then the activity component to be created is set to an empty activity component by setting the corresponding class name, including: When executing the method for creating a new activity component, if the activity component to be created is a homepage activity component, the existence of a homepage activity component is determined by the creation and destruction information of the homepage activity component. If a homepage activity component already exists, the current activity component to be created will be set to an empty activity component by setting the corresponding class name.
6. The method according to claim 1, characterized in that, Also includes: The method to launch the active component in the launch context; When the launch activity component method of the context is executed to launch the homepage activity component, the second splash screen activity component is launched by adding a second intent information of a tag. The second intent information of the tag indicates that the existing homepage activity component is launched and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the second splash screen activity component is the homepage activity component.
7. The method according to claim 1, characterized in that, The first splash screen activity component is initiated by the component information instruction of the first intent information.
8. A starting device, characterized in that, include: The startup module is used to launch the method for creating a new active component; The determination module is used to determine whether the activity component to be created is a homepage activity component when the new activity component method is executed; The settings module is used to, when executing the method to create a new activity component, if the activity component to be created is a homepage activity component and a homepage activity component already exists, set the corresponding class name to point the activity component to be created to an empty activity component. The closing module is used to close the empty activity component and start the first splash screen activity component by adding a first intent information of the label. The first intent information of the label indicates that the existing homepage activity component is started and the activity component created after the existing homepage activity component is deleted. The target activity component attribute of the first splash screen activity component is the homepage activity component.
9. A terminal device, characterized in that, include: One or more processing devices; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processing devices, the one or more processing devices perform the method as described in any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processing device, it implements the method as described in any one of claims 1-7.