Application program starting method and electronic equipment
By displaying and migrating the startup window during the application's cold startup process, the problem of slow response speed and splash screen during the application's cold startup process is solved, improving the user experience.
Patent Information
- Application Number
- CN202311682916.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-08
- Publication Date
- 2025-06-17
AI Technical Summary
There are slow response and splash screen issues during cold startup of the application, especially when two or more active components are started, the first active component is not visible and the second active component is visible.
During the cold startup of the application, launch windows attached to the upper layer of the active component are displayed based on user operations and these windows are migrated between the active components. The specific steps include displaying the startup window during the life cycle of the first active component, migrating to the second active component, and canceling the migration when the second active component is located in a different task stack, so that the startup window remains in the first task stack until the second task stack generates a new startup window.
It achieves the improvement of the response speed during the cold startup of the application, avoids the problem of splashing screens, and makes the user experience better.
Smart Images

Figure CN120162089A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of terminals, and in particular, to an application startup method and an electronic device. Background Art
[0002] The cold startup of an application refers to the process of a user installing or opening an application for the first time. During the cold startup of an application, the startup of two or more activity components (Activities) may be involved. Taking the startup of two Activities as an example, when the first Activity is invisible, the second visible Activity is usually set in a different task stack from the first Activity.
[0003] Based on this, if no startup window is added to these two Activities when starting them, then after the user clicks the icon corresponding to the application, they will enter the startup interface of the application after waiting for a long time, making the user feel that the response speed of the application is slow and the startup is not smooth. If a startup window is added to these two Activities when starting them, due to the asynchrony in the creation process of the layer of the second Activity and the layer of its corresponding task stack, then after the user clicks the icon corresponding to the application, there will be a flash screen problem with a certain probability. Summary of the Invention
[0004] Embodiments of this application provide an application startup method and an electronic device, which can solve problems such as slow response speed and flash screen during the cold startup process of an application.
[0005] In a first aspect, an embodiment of this application provides an application startup method, including: based on a cold startup operation of a user on a first application, when the first application starts at least one invisible first activity component, within the first life cycle corresponding to the first activity component, display a first startup window attached to the upper layer of the first activity component, where the first activity component is located in a visible first task stack, and the first task stack is associated with the first activity component; after the first life cycle ends, when the first application starts a visible second activity component, migrate the first startup window to the second activity component, and during the process of migrating the first startup window, determine whether the second activity component is located in an invisible second task stack, and the second task stack is associated with the second activity component; when the second activity component is located in the second task stack, cancel the migration of the first startup window, so that the first startup window continues to use the first task stack, where the first startup window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration; when a second startup window is generated for the second activity component and the second task stack and the second startup window is displayed, destroy the first startup window and display the second startup window.
[0006] The application startup method shown in the embodiments of the present application changes the migration logic of the startup window for the case where two or more activity components are started during the cold startup process of the application and the first activity component is invisible, so that the startup window migrates within the same task stack and does not migrate across task stacks. In this way, the response speed of the application cold startup process can be fast, and the splash screen problem can be avoided.
[0007] In one implementation, it further includes: when the second activity component is not located in the second task stack, completing the migration of the first startup window in the first task stack, and displaying the first startup window attached to the upper layer of the second activity component based on the first task stack. By adopting this implementation, by judging whether the second activity component is located in the second task stack, it can be ensured that the startup window migrates within the same task stack and does not migrate across task stacks. In this way, the response speed of the application cold startup process can be fast, and the splash screen problem can be avoided.
[0008] In one implementation, before displaying the first startup window attached to the upper layer of the first activity component, it further includes: determining whether the first application enables the startup window function; when the first application enables the startup window function, obtaining the display content of the first startup window, and creating the first startup window according to the display content. By adopting this implementation, the specific method of creating the startup window is shown. In this way, by setting the startup window, users can feel that the application has been started quickly, improving the user experience.
[0009] In one implementation, after determining whether the first application enables the startup window function, it further includes: when the first application does not enable the startup window function, determining whether the first application can add the first startup window; when the first application can add the first startup window, obtaining the display content of the first startup window, and creating the first startup window according to the display content. By adopting this implementation, when the application side does not enable the startup window function, the system side can determine whether the first application can add the startup window, and add the startup window when the first application can add the startup window. In this way, by setting the startup window, users can feel that the application has been started quickly, improving the user experience.
[0010] In one implementation, after the end of the first life cycle, when a second activity component launched by the first application becomes visible, the following steps are further included: creating a first layer corresponding to the second startup window based on the second activity component, processing the first layer, and sending the processed first layer to the SurfaceFlinger. By adopting this implementation, it shows that the first layer can be processed immediately when the second activity component is launched. In the case where there is asynchrony in the processing of the layer by the second activity component and the second task stack, by enabling the first startup window to retain the use of the first task stack, the first startup window and the second startup window can be connected in succession, avoiding the problem of screen flashing.
[0011] In one implementation, the second activity component and the second task stack generate a second startup window and display the second startup window, including: creating a second layer corresponding to the second startup window based on the second task stack, processing the second layer, and sending the processed second layer to the SurfaceFlinger; after the SurfaceFlinger receives the first layer and the second layer, synthesizing the first layer and the second layer to generate the second startup window; sending the second startup window to the display driver through the SurfaceFlinger. By adopting this implementation, the second task stack processes the second layer after the second activity component. In the case where there is asynchrony in the processing of the layer by the second activity component and the second task stack, by enabling the first startup window to retain the use of the first task stack, the first startup window and the second startup window can be connected in succession, avoiding the problem of screen flashing.
[0012] In one implementation, creating a second layer corresponding to the second startup window based on the second task stack, processing the second layer, and sending the processed second layer to the SurfaceFlinger includes: calculating the size of the second layer and updating the drawing state of the second layer; after calculating the size of the second layer and updating the drawing state of the second layer, sending the second layer to the SurfaceFlinger. By adopting this implementation, the specific processing method of the second task stack for the second layer is shown.
[0013] In one implementation, after the second startup window is displayed, the following steps are further included: when a preset condition is met, switching from displaying the second startup window to displaying the application interface corresponding to the first application, where the preset condition includes: the application interface is drawn completely or at least a part of the interface element data in the application interface is drawn completely, and the interface element data includes at least one of the title bar and the navigation bar in the application interface. By adopting this implementation, after the startup window display ends, the application interface can be entered to complete the cold start process of the application program, and no screen flashing occurs during this process.
[0014] Second aspect, an embodiment of the present application further provides an application startup method, including: based on a cold startup operation of a user on a first application, when at least one invisible first activity component is started in the first application, within a first lifecycle corresponding to the first activity component, display a third startup window attached to the upper layer of the first activity component, where the first activity component is located in a visible first task stack, and the first task stack is associated with the first activity component; after the first lifecycle ends, when a visible second activity component is started in the first application, migrate the third startup window to the second activity component, and during the process of migrating the third startup window, preset the layer attribute of a second task stack associated with the second activity component to be visible; complete the migration of the third startup window in the second task stack, and display the third startup window based on the visible second task stack.
[0015] The application startup method shown in the embodiment of the present application is directed to the situation where two or more activity components are started during the cold startup process of an application and the first activity component is invisible. While maintaining the migration logic of the startup window, change the attribute of the second task stack, and pre-change its invisibility so that the second activity component is started in a visible second task stack. In this way, the startup window can always be displayed in the second task stack, and there will be no problem that the startup window is invisible due to the invisibility of the task stack, and thus the flash screen problem will not occur. It can make the response speed of the application cold startup process fast and avoid the flash screen.
[0016] In one implementation, before displaying the third startup window attached to the upper layer of the first activity component, it further includes: determining whether the first application enables the startup window function; when the first application enables the startup window function, obtaining the display content of the third startup window, and creating the third startup window according to the display content. By adopting this implementation, the specific method of creating the startup window is shown. In this way, by setting the startup window, the user can feel that the application has been started quickly, improving the user experience.
[0017] In one implementation, after determining whether the first application enables the startup window function, it further includes: when the first application does not enable the startup window function, determining whether the first application can add the third startup window; when the first application can add the third startup window, obtaining the display content of the third startup window, and creating the third startup window according to the display content. By adopting this implementation, when the application side does not enable the startup window function, the system side can determine whether the first application can add the startup window, and add the startup window when the first application can add the startup window. In this way, by setting the startup window, the user can feel that the application has been started quickly, improving the user experience.
[0018] In one implementation, after displaying the third startup window based on the visible second task stack, the following is further included: when a preset condition is met, switching from displaying the third startup window to displaying the application interface corresponding to the first application, where the preset condition includes: the application interface is drawn completely or at least a part of the interface element data in the application interface is drawn completely, and the interface element data includes at least one of the title bar and the navigation bar in the application interface. By adopting this implementation, after the startup window display ends, the application interface can be entered to complete the cold start process of the application program, and there is no splash screen during this process.
[0019] In a third aspect, an embodiment of the present application further provides an application program startup device, including: a first display module, which is used to display a first startup window attached to the upper layer of the first active component within the first life cycle of the first active component when the first application starts at least one invisible first active component based on the cold start operation of the user on the first application, where the first active component is located in the visible first task stack, and the first task stack is associated with the first active component. A first migration module, which is used to migrate the first startup window to the second active component when the first application starts a visible second active component after the first life cycle ends, and determine whether the second active component is located in an invisible second task stack during the process of migrating the first startup window, where the second task stack is associated with the second active component. A first cancellation module, which is used to cancel the migration of the first startup window when the second active component is located in the second task stack, so that the first startup window retains the use of the first task stack, where the first startup window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration. A second display module, which is used to destroy the first startup window and display the second startup window when the second startup window is generated based on the second active component and the second task stack and sent for display.
[0020] The application program startup device shown in the embodiment of the present application changes the migration logic of the startup window for the case where two or more active components are started during the cold start process of the application program and the first active component is invisible, so that the startup window migrates within the same task stack instead of across task stacks. In this way, the response speed of the application program cold start process can be fast, and the splash screen problem can be avoided.
[0021] Fourth aspect, an embodiment of the present application further provides an application startup device, including: a third display module, configured to, based on a cold startup operation of a user on a first application, when at least one invisible first activity component is started by the first application, within a first lifecycle corresponding to the first activity component, display a third startup window attached to an upper layer of the first activity component, where the first activity component is located in a visible first task stack, and the first task stack is associated with the first activity component. A second migration module, configured to, after the end of the first lifecycle, when a visible second activity component is started by the first application, migrate the third startup window to the second activity component, and during the process of migrating the third startup window, preset the layer attribute of a second task stack associated with the second activity component to be visible. A fourth display module, configured to complete the migration of the third startup window in the second task stack and display the third startup window based on the visible second task stack.
[0022] The application startup device shown in the embodiment of the present application, for the case where two or more activity components are started during the cold startup process of an application and the first activity component is invisible, while maintaining the migration logic of the startup window, changes the attribute of the second task stack, pre-changes its invisibility, so that the second activity component is started in a visible second task stack. In this way, the startup window can always be displayed in the second task stack, and there will be no problem that the startup window is invisible due to the invisibility of the task stack, and thus the splash screen problem will not occur, which can make the response speed of the cold startup process of the application fast and avoid the splash screen.
[0023] Fifth aspect, an embodiment of the present application further provides an electronic device, including: a processor and a memory, where program instructions are stored in the memory, and when the program instructions are executed by the processor, the electronic device is caused to execute the application startup method as described in the first aspect and any of its implementation manners or as described in the second aspect and any of its implementation manners above.
[0024] Sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are run on an electronic device, the electronic device is caused to execute the application startup method as described in the first aspect and any of its implementation manners or as described in the second aspect and any of its implementation manners above.
[0025] Seventh aspect, an embodiment of the present application further provides a computer program product, and when the computer program product is run on an electronic device, the electronic device is caused to execute the application startup method as described in the first aspect and any of its implementation manners or as described in the second aspect and any of its implementation manners above.
[0026] Understandably, the electronic devices, computer-readable storage media, and computer program products provided in the above aspects are all applied to the corresponding methods provided above. Therefore, the beneficial effects they can achieve can refer to the beneficial effects in the corresponding methods provided above, and will not be elaborated here. Description of the Drawings
[0027] Figure 1 is a flowchart of the cold start method of Application A;
[0028] Figure 2 is the first schematic diagram of the cold start scenario of Application A;
[0029] Figure 3 is a schematic diagram of the visible relationship between active components and the task stack;
[0030] Figure 4 is the second schematic diagram of the cold start scenario of Application A;
[0031] Figure 5 is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application;
[0032] Figure 6 is a schematic diagram of the software structure of the electronic device provided in the embodiment of the present application;
[0033] Figure 7 is the first flowchart of the application program start method provided in the embodiment of the present application;
[0034] Figure 8 is the second flowchart of the application program start method provided in the embodiment of the present application;
[0035] Figure 9 is the third flowchart of the application program start method provided in the embodiment of the present application;
[0036] Figure 10 is a schematic diagram of the application program start device provided in the embodiment of the present application;
[0037] Figure 11 is a schematic diagram of the application program start device provided in another embodiment of the present application;
[0038] Figure 12 is a schematic diagram of the structure of the application program start device provided in the embodiment of the present application. Detailed Embodiments
[0039] The technical solutions of the embodiments of the present application will be clearly described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0040] In the description of the present application, unless otherwise specified, " / " means "or". For example, A / B may represent A or B. The "and / or" herein is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, "at least one" means one or more, and "a plurality of" means two or more. The words such as "first" and "second" do not limit the quantity and execution order, and the words such as "first" and "second" do not necessarily limit being different.
[0041] It should be noted that in the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.
[0042] The application scenarios of the embodiments of the present application will be described below first.
[0043] An electronic device is usually installed with a variety of application programs (Appliaction, App). The cold start of an application program refers to the process of the user installing or opening the application program for the first time. During the cold start of the application program, the application program needs to perform a series of initialization operations, including loading resources, setting the environment, preheating the cache, etc.
[0044] An activity component is one of the four major components of Android and is a component representing a user interface, including various user interface elements such as buttons, text boxes, images, etc. An activity can manage the life cycle and state transition when the user interacts with the application program. Each activity has its own life cycle, including stages such as creation, start, pause, resume, stop, and destruction. In different stages of the life cycle, an activity can be configured with specific operations to manage the behavior and state of the application program. In an application program, multiple activities can work together to jointly constitute the overall user interface and functions of the application program.
[0045] During the cold start of an application, the start of two or more Activities may be involved.
[0046] The following takes the application as Application A, and Application A starts two Activities during cold start, such as an invisible pre-start activity (PreStartActivity) and a visible public start activity (StartPublicActivity), for exemplary illustration. It should be noted here that the public start activity can be visible or invisible. The following examples of this application are all illustrated with the public start activity being visible, which does not mean that this Activity must have visibility.
[0047] Figure 1 It is a flowchart of the cold start method of Application A.
[0048] As Figure 1 shown, after the user clicks the icon of Application A, the electronic device performs the following steps S1 - S10.
[0049] Step S1, based on the user's click operation on the icon, the electronic device starts an invisible Activity1 in Application A. Among them, Application A is an application that is not running in the background, and Activity1 can be a pre-start activity.
[0050] A pre-start activity refers to a hidden Activity that is started in advance before the application starts. This activity can perform the initialization and resource loading of the application in the background to accelerate the cold start time of the application, so that the application can respond to the user's request faster when it is actually started.
[0051] The implementation methods of pre-start activities in different applications are different.
[0052] Exemplarily, in Application A, the implementation method of the pre-start activity can be as follows:
[0053] Declare the pre-start activity in the manifest file (Manifest) of Application A, and set a transparent theme for the pre-start activity to ensure that the pre-start activity is invisible when it starts. During the process of Application A starting the pre-start activity, the initialization and resource loading operations of Application A can be executed. For example, preloading data, establishing a network connection, etc.
[0054] Step S2, after the electronic device starts Activity1, it determines whether Application A has enabled the Starting Window function.
[0055] Among them, the startup window can be the preview window of the Activity, which is used to inform the user that the application has started before the application interface of the application is displayed. The startup window is managed by the WindowManagerService, and the WindowManagerService is responsible for the startup and termination of the startup window.
[0056] Specifically, the ActivityManagerService can determine whether the startup window of the Activity needs to be displayed. In the case where it needs to be displayed, the ActivityManagerService notifies the WindowManagerService to display a startup window for the Activity that is being started. After receiving the notification, the WindowManagerService creates the startup window through the PhoneWindowManager.
[0057] The above process can be executed only after the electronic device determines that the application has enabled the startup window function.
[0058] Specifically, the electronic device can determine whether Application A has enabled the startup window function in the following way.
[0059] Exemplarily, after starting the pre-start activity, the electronic device can detect whether there is a flag bit B corresponding to the startup window in Application A, and determine whether a layout file is specified as the background of the startup window according to the flag bit B. If there is a specified layout file, it is determined that Application A has enabled the startup window function. In fact, the electronic device can also determine whether Application A has enabled the startup window function in other ways, which will not be elaborated in this application. In the case where Application A has enabled and not enabled the startup window function, some problems are faced.
[0060] The following specifically describes the case where Application A has not enabled the startup window function.
[0061] In the case where Application A has not enabled the startup window function, the electronic device can execute step S3.
[0062] Step S3, in the case where Application A has not enabled the startup window function, the electronic device sequentially invokes the life cycle of Activity1 and the life cycle of Activity2. Among them, Activity2 can be a visible public startup activity.
[0063] Figure 2 It is the first schematic diagram of the cold start scenario of Application A.
[0064] Such as Figure 2As shown, during the process of application development, developers may turn off the startup window function for various reasons (for example, the initial style of the startup window is simple, or the application provider needs to display advertisements on the startup interface). In this case, when the electronic device determines that the application does not enable the startup window function, the activity management service will not send a notification to the window management service. After the application calls and completes two Activities without a startup window, the application interface is displayed.
[0065] For example, after the user clicks on the icon 101 of Application A, Application A performs a series of operations such as loading the layout file of the application interface, generating the application interface layout, loading the interface element data, and drawing the first interface 102 based on the interface element data without a startup window. That is, after calling the life cycles of Activity1 and Activity2, the first interface 102 is displayed.
[0066] Therefore, after the user clicks on the icon 101, the electronic device needs to spend a relatively long time calling the life cycles of Activity1 and Activity2 to complete the page loading, and during this process, the user's vision always stays on the desktop of the electronic device. In this way, it takes a relatively long time for the electronic device to jump to the first interface 102 after the user clicks on the icon 101, resulting in the user feeling that the startup of Application A is not responsive and the page transition is slow, which affects the user experience.
[0067] The following specifically describes the situation where Application A enables the startup window function.
[0068] When Application A enables the startup window function, the electronic device can execute steps S4 - S10.
[0069] Step S4, when Application A enables the startup window function, the electronic device obtains the display content of the startup window and creates a startup window based on the display content.
[0070] Step S5, the electronic device displays the startup window attached to the upper layer of Activity1 during the life cycle of Activity1.
[0071] Each application usually has one or more corresponding task stacks. A task stack is a mechanism in the Android system for managing Activities and is a Last In First Out (LIFO) data structure to track the order and status of each Activity in the application. Activities with different task attributes are usually set in different task stacks.
[0072] When the application starts, the first launched Activity is created and added to the top of the task stack. Subsequently launched Activities are sequentially added to the task stack and arranged in the launch order. In this way, the task stack can manage and control the lifecycle and display order of these Activities. Different Activities can also be added to different task stacks, and multiple task stacks run simultaneously so that each task stack can independently handle different tasks.
[0073] The visibility of both the launch window and the Activity is closely related to the task stack.
[0074] Figure 3 It is a schematic diagram of the visibility relationship between the active component and the task stack.
[0075] Such as Figure 3 As shown, based on the management relationship of the Activity by the above task stack, when the attribute of the task stack is invisible, the Activities in it are all invisible. When the attribute of the task stack is visible, the Activity is visible. If the layer created by the Activity itself is invisible, even if the attribute of the task stack is visible, the user cannot see any layer.
[0076] Correspondingly, the visibility of the launch window depends on the visibility of the task stack. When the attribute of the task stack is invisible, the launch window attached to it is invisible. When the attribute of the task stack is visible, the launch window attached to it is visible.
[0077] For example, the task stack where the pre-launch activity is located is usually visible, but the layer created by the pre-launch activity itself is invisible. Therefore, a launch window needs to be added to the pre-launch activity at startup, covering the invisible layer. Since the task stack where the pre-launch activity is located is visible, the added launch window is visible. In this way, it can be avoided that the user feels that the cold start process of Application A responds too slowly.
[0078] The electronic device can display the launch window attached to the upper layer of the pre-launch activity during the lifecycle of the pre-launch activity.
[0079] Step S6, after the lifecycle of Activity1 ends, the electronic device launches and makes Activity2 visible in Application A.
[0080] When the public startup activity is visible and Activity2 is the visible public startup activity, after the electronic device starts the public startup activity, the public startup activity creates a layer (Surface) L1 corresponding to the startup window. The system service (System_server) of the electronic device adds Surface L1 to the system user interface (SystemUI) so that SystemUI immediately processes Surface L1, calculates the layer size of Surface L1, and updates the layer drawing state of Surface L1. In this way, the public startup activity immediately sends Surface L1 to the SurfaceFlinger to display Surface L1.
[0081] Step S7, the electronic device migrates the startup window to the public startup activity.
[0082] In the case where the pre-startup activity is invisible and the public startup activity is visible, based on the native mechanism of Android, the migration of the startup window from the pre-startup activity to the public startup activity will necessarily be triggered. This is because when there is at least one invisible Activity and these Activities are attached with a startup window, the native mechanism of Android will ensure that the startup window migrates sequentially on these invisible Activities until it migrates to the first visible Activity to avoid a splash screen.
[0083] It should be noted here that the pre-startup activity and the public startup activity are located in different task stacks (Task Stack). The pre-startup activity is an internally used activity and usually does not need to interact with the user or other application programs. Therefore, the pre-startup activity can be set in an independent task stack to separate it from the main application task stack, so as to better manage and control the activity behavior therein. At the same time, it can also ensure that the pre-startup activity is not occupied by other application programs.
[0084] The public startup activity is used to respond to external trigger events and may need to interact with the user or other application programs. Therefore, the public startup activity can be set in the main application task stack to facilitate user navigation and interaction within the application.
[0085] The process of the electronic device migrating the startup window not only involves the transfer of the startup window between the pre-startup activity and the public startup activity, but also involves the switching of the task stack. Specifically, after the public startup activity starts, the operating system determines the task stack to which the public startup activity belongs and switches from the task stack where the pre-startup activity is located to the task stack where the public startup activity is located.
[0086] The task stack of the public startup activity has its initial property usually defaulted to invisible. Therefore, the startup window migrated to this task stack is invisible at this time.
[0087] Step S8, the electronic device calculates the layer size of the migrated startup window and updates the layer drawing state of the startup window.
[0088] After the task stack layer SurfaceL2 corresponding to the public startup activity is sent to SurfaceFlinger, SurfaceL2 becomes visible. At this time, when both SurfaceL1 and SurfaceL2 are visible, the startup window can display an animation effect.
[0089] Specifically, the Surface in Activity and the Surface in the task stack are different. In Activity, the view hierarchy can be created by setting the layout file or using code to determine the display effect of the UI interface through the view hierarchy. Among them, each view can be regarded as a Surface, and the Surfaces are stacked in the order of addition, and the last added view is at the top layer. The Surface in Activity is used to manage the display effect of the UI interface.
[0090] The Surface in the task stack refers to the background stack structure used to manage Activity instances. Each time a new Activity is started, the Activity is pushed to the top of the task stack and becomes the current active Activity. Therefore, when the current active Activity is at the top of the task stack and other Activities are below it, a hierarchical structure is formed. The Surface in the task stack is used to control the hierarchical relationship and navigation order of Activities.
[0091] The functions of the Surface of Activity and the Surface in the task stack are different, and their appearance order is also different. The Surface of Activity is created and displayed during the life cycle of Activity, while the Surface in the task stack is managed and displayed according to the startup order of Activities.
[0092] That is to say, the display of the layer in the task stack lags behind that of the layer in Activity.
[0093] Correspondingly, the display of SurfaceL1 and SurfaceL2 is asynchronous. SurfaceL1 is displayed in step S6 before SurfaceL2, and SurfaceL2 is displayed in step S8, thus causing a splash screen.
[0094] Figure 4 This is a second schematic diagram of the cold start scenario of application A.
[0095] like Figure 4 As shown, during the asynchronous display of SurfaceL1 and SurfaceL2, the display of SurfaceL2 depends on the task stack visibility (Task visible) set during the implementation of step S7. In the implementation of step S7, SurfaceL2 will be added to the pending event. In step S8, when the task stack corresponding to the public startup activity is established, the addStartingWindow task will be started, and the performSurfacePlacement method will be triggered based on the task, so that the surface layout can process the pending transaction, and the pending transaction will be added to SystemUI, so that SystemUI can process SurfaceL2, calculate the layer size of SurfaceL2 and update the layer drawing state of SurfaceL2. The public startup activity will send SurfaceL2 to SurfaceFlinger to display SurfaceL2.
[0096] It should be noted here that SurfaceL1 and SurfaceL2 are processed in different transactions of SystemUI, and SurfaceFlinger will process all collected transactions centrally before synthesizing each frame of image.
[0097] Therefore, if SurfaceL1 and SurfaceL2 are sent to SurfaceFlinger before the next frame of image synthesis, SurfaceFlinger can process SurfaceL1 and SurfaceL2 at the same time when the next frame of image synthesis is performed, and no screen flashing will occur.
[0098] If SurfaceL1 is sent to SurfaceFlinger before the next frame of image synthesis, and SurfaceL2 is not sent to SurfaceFlinger before the next frame of image synthesis, SurfaceFlinger traverses the Surfaces to determine visibility. At this time, SurfaceL1 is visible, and the task stack corresponding to the public startup activity is invisible, then SurfaceL1 cannot be displayed, which is prone to the following errors: Figure 4 The splash screen shown. In other words, the splash screen is actually a probabilistic event.
[0099] Step S9, the electronic device displays a startup window during the life cycle of the public startup activity.
[0100] Step S10, after the electronic device displays the startup window, it displays the application interface corresponding to the public startup activity.
[0101] In this way, Application A completes the cold start process.
[0102] During the cold start process of the above Application A, since the invisible Activity1 and the visible Activity2 are usually in different task stacks, there is a certain probability of a splash screen problem during the process of migrating the startup window based on these two Activities.
[0103] To solve the above problem, an embodiment of the present application discloses an application startup method, which can be applied to an electronic device.
[0104] The application startup method provided by the embodiment of the present application can be applied to an electronic device with a display function. Among them, the electronic device includes but is not limited to mobile phones, tablet computers, personal computers, workstation devices, large-screen devices (such as: smart screens, smart TVs, etc.), wearable devices (such as: smart bracelets, smart watches), handheld game consoles, home game consoles, virtual reality devices, augmented reality devices, mixed reality devices, etc., in-vehicle intelligent terminals, etc.
[0105] Figure 5 It is a schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present application.
[0106] As Figure 5 shown, the electronic device 100 may include a processor 110, a memory 120, an antenna 10, an antenna 20, a mobile communication module 130, a wireless communication module 140, a sensor module 150, a display screen 160, etc. Among them, the sensor module 150 may include a touch sensor 150A.
[0107] It can be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0108] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0109] The memory 120 may be used to store computer-executable program codes, and the executable program codes include instructions. The memory 120 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.). In addition, the memory 120 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the memory 120 and / or the instructions stored in the memory provided in the processor.
[0110] The wireless communication function of the electronic device 100 may be implemented by the antenna 10, the antenna 20, the mobile communication module 130, the wireless communication module 140, the modem processor, and the baseband processor, etc.
[0111] The antennas 10 and 20 are used to transmit and receive electromagnetic wave signals.
[0112] The mobile communication module 130 may provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 130 may receive electromagnetic waves by the antenna 10, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 130 may also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 10 for radiation.
[0113] The wireless communication module 140 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 20, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive the signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 20 for radiation.
[0114] The electronic device 100 implements the display function through the GPU, the display screen 160, and the application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 160 and the application processor. The GPU is used to execute mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change the display information.
[0115] The display screen 160 is used to display images, videos, etc. The display screen 160 includes a display panel. The display panel may adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc.
[0116] The touch sensor 150A, also known as the "touch control device". The touch sensor 150A can be disposed on the display screen 160. The touch sensor 150A and the display screen 160 form a touch screen, also known as the "touch control screen". The touch sensor 150A is used to detect touch operations acting thereon or nearby. The touch sensor can transmit the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 160. In some other embodiments, the touch sensor 150A can also be disposed on the surface of the electronic device 100, at a different position from the display screen 160.
[0117] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the Android system with a layered architecture as an example, the software structure of the electronic device 100 is exemplarily described.
[0118] Figure 6 It is a schematic diagram of the software structure of the electronic device provided by the embodiments of the present application.
[0119] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely the application layer, the application framework layer, the Android runtime and the system libraries, and the kernel layer.
[0120] The application layer may include a series of application packages.
[0121] Such as Figure 6 shown, the application packages may include applications such as battery management, camera, gallery, calendar, call, map, navigation, music, video, short message, etc.
[0122] Among them, each application contains one or more layers. Each application performs the layer drawing (Render) operation separately according to its own application design, and sends all the drawn layers to the SurfaceFlinger in the system libraries. The application can send a layer to the SurfaceFlinger when a layer is drawn, or can send the drawn layer to the SurfaceFlinger when the set first part of the interface element data is drawn in a layer.
[0123] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.
[0124] As Figure 6 shown, the application framework layer may include a window manager, an input manager (InputManager), a sensor manager (SensorManager), a phone manager, a resource manager, a notification manager, etc.
[0125] The input manager can be used to monitor user input events, such as click events, swipe events, etc. performed by a user's finger on the display screen 193 of the electronic device 100. By monitoring the input events, the electronic device 100 can determine whether the electronic device is being used.
[0126] The sensor manager is used to monitor data returned by various sensors in the electronic device, such as motion sensor data, proximity light sensor data, temperature sensor data, etc. Using the data returned by each sensor, the electronic device can determine whether it is jittery or whether the display screen 160 is blocked, etc.
[0127] The Android Runtime includes a core library and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0128] The core library consists of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core library of Android.
[0129] Among them, all the layers in the application framework layer (including visible layers and invisible layers) will form a layer list, defined as the all list (ListAll). The surface compositor selects the visible layers from ListAll to form a visible layer list, defined as the display list (DisplayList). Then, the surface compositor can select an idle frame buffer from three reusable frame buffers (FrameBuffer) and perform a composition operation on this frame buffer according to the application configuration information. Among them, the application configuration information can stipulate that a certain layer is at the bottom, a certain layer is at the top, a certain area is the visible area, and a certain area is the transparent area. In this way, based on the composition operation, the frame buffer stacks the layers included in DisplayList together to obtain the final picture to be displayed. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection. The system library can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing library (such as: OpenGL ES), 2D graphics engine (such as: SGL), SurfaceFlinger, etc.
[0130] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
[0131] The media library supports the playback and recording of various common audio and video formats, as well as static image files, etc. The media library can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0132] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, composition, and layer processing, etc.
[0133] The 2D graphics engine is the drawing engine for 2D drawing.
[0134] SurfaceFlinger is used to manage and compose the graphical interfaces of applications and display them on the device's display screen. For example: An application can provide image data to SurfaceFlinger. After receiving the layers from the application, SurfaceFlinger can put them into a queue to be processed. SurfaceFlinger can traverse the queue to be processed in a specific order and compose the layers according to the attributes of each layer. After the layer composition is completed, SurfaceFlinger can send the layer to the display driver in the kernel layer.
[0135] The kernel layer is the layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
[0136] The display driver can transfer the layers transmitted by SurfaceFlinder to the display screen 160 for display.
[0137] It can be understood that the structure schematically shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure can be implemented in hardware, software, or a combination of software and hardware.
[0138] Figure 7 This is the first flowchart of an application startup method provided by the embodiments of the present application.
[0139] As Figure 7 shown, the method may include the following steps S101 - S104.
[0140] Step S101, based on the user's cold startup operation of the first application, when at least one invisible first Activity is started in the first application, within the first life cycle corresponding to the first Activity, display the first startup window attached to the upper layer of the first Activity.
[0141] Among them, the first Activity is located in the visible first task stack, and the first task stack is associated with the first Activity.
[0142] The cold start operation of the first application by the user can be a click operation on the icon corresponding to the first application by the user through the touch screen, mouse, or stylus. It should be noted here that the cold start operation of the first application by the user includes, but is not limited to, the user's click operation, and can also be the operation of the user inputting voice through the voice assistant, or the operation of the user inputting a preset opening gesture. For example, when detecting the instruction of the user's voice input "open the first application", it is determined that a cold start operation for the first application is detected. When detecting a preset gesture input by the user based on the sensors built in the electronic device, if the preset gesture matches the preset gesture for starting the first application, it is determined that a cold start operation for the first application is detected. The specific operation form of the cold start operation in the embodiments of the present application is not limited. In this way, the user realizes the interaction with the first application to trigger the startup process of the first application.
[0143] The first application is an application that is not running in the background. After triggering the startup process of the first application, the operating system allocates the required resources and memory for the first application, and starts to load the code and data of the first application, and starts the first Activity set in the first application.
[0144] In the embodiment of the present application, two or more Activities for cold start are set in the first application, and at least one of the frontmost Activities is an invisible Activity, and the invisible Activity and the visible Activity are set in different task stacks. For example, when two Activities are set in the first application, the first Activity can be an invisible pre-start activity, and the second Activity can be a visible common start activity. When three Activities are set in the first application, the first Activity can be an invisible pre-start activity, the second Activity can be a visible common start activity or an invisible common start activity, and the third Activity can be a visible home root activity (HomeRootActivity). Among them, when there are multiple invisible Activities set in the front, the startup window attached to the Activity is visible only until the visible Activity is started. If only the first Activity is an invisible Activity and the second and third Activities are both visible Activities, then starting from the second Activity, the startup window attached to the Activity is visible. In the embodiment of the present application, only two Activities are set in the first application, the first one is an invisible Activity, and the second one is a visible Activity for exemplary illustration. In fact, the present application does not limit the number of Activities set in the first application.
[0145] In one implementation, when the operating system detects that a first flag bit is set in the first application, it can determine that the first application will set the first invisible Activity and the second visible Activity in different task stacks. Based on this, it is determined to execute the application startup method in the embodiment of the present application in such a scenario. It should be noted here that the first flag bit has different setting methods in different operating systems, and the embodiment of the present application does not limit the specific form of the first flag bit.
[0146] The first Activity is the first Activity set in the first application. In the following embodiments of the present application, the first Activity is used as the pre-start activity for exemplary illustration, and the embodiment of the present application does not limit the specific type of the first Activity.
[0147] Each Activity has its own life cycle, and each life cycle usually includes multiple stages such as creation, start, running, and destruction. The specific implementation process of each life cycle depends on the developer's design process.
[0148] For example, in the first life cycle, during the creation stage of the pre - startup activity, the Activity can perform initialization operations, such as setting the layout, binding views, etc. During the startup stage of the pre - startup activity, the Activity can perform some preparatory work. At this time, the Activity can be in the foreground, register listeners, and start the window, etc. During the running stage of the pre - startup activity, the Activity can save temporary data or stop the running startup window. It can also release the occupied resources when the Activity is about to end and unregister listeners, etc. During the destruction stage of the pre - startup activity, the Activity can perform final cleanup work, such as further releasing resources, unbinding, etc.
[0149] That is to say, during the startup stage and the running stage of the pre - startup activity, the first startup window attached to the upper layer of the Activity can be displayed.
[0150] Since the pre - startup activity is the first Activity to be started in the first application, usually, the task stack has not been established in the current first application yet. Instead, an independent task stack pre - set for the pre - startup activity will be started, that is, the first task stack. The attribute of the first task stack is usually set to be visible. In this way, the pre - startup activity is located in the visible first task stack.
[0151] It should be noted here that if an independent task stack has not been set for the pre - startup activity in advance and there is no task stack directly matching the pre - startup activity in the first application, then, if a first flag is set in the startup intent (Intent) mechanism corresponding to the first application, and the first flag is, for example, FLAG_ACTIVITY_NEW_TASK, a new task stack can be created according to the first flag, and this new task stack can also be used as the first task stack. The specific creation method of the first task stack in the embodiments of the present application is not limited.
[0152] Figure 8 It is the second flowchart of an application startup method provided by the embodiments of the present application.
[0153] Such as Figure 8 shown, in one implementation, step S101 includes steps S1011 - S1012.
[0154] Step S1011, determine whether the first application enables the startup window function.
[0155] After the pre - startup activity enters the first life cycle, the electronic device can detect whether there is a second flag bit corresponding to the startup window in the first application and determine whether a layout file is specified as the background of the startup window according to the second flag bit. If there is a specified layout file, it is determined that the first application enables the startup window function.
[0156] Exemplarily, the first application is configured with a manifest file, traverse the manifest file to view the Activities for cold start, that is, view the pre-launched activities and the common launched activities, and at these Activities' <activity>Detect the second marker bit under the label (the second marker bit can be, for example, the Theme marker). After detecting the Theme marker, determine whether the WindowBackground property or other related properties in the Theme marker are used to specify a layout file as the background of the startup window. In this way, it can be determined that the first application enables the startup window function.
[0157] When the electronic device detects a cold start operation for the first application, it can also read in the manifest file of the first application whether there is information enabling the startup window, and determine whether the first application enables the startup window function according to the read return value.
[0158] Step S1012, when the first application enables the startup window function, obtain the display content of the first startup window and create the first startup window according to the display content.
[0159] Among them, obtaining the display content of the startup window and creating the startup window according to the display content is actually a process of executing the Android native process, which is the normal display method of the startup window.
[0160] The display content of the first startup window can be a preset picture or animation effect, and the first startup window can be created according to the preset picture or animation effect.
[0161] Taking the display content of the first startup window as a preset picture as an example for illustration. The preset picture can be used as the background of the first startup window, filled in the first startup window, and the icon of the first application can be set on the preset picture.
[0162] In order to provide users with a better visual experience, the preset picture can be set with multiple colors. For example, black and dark blue set to adapt to the night mode of the electronic device, and white and light gray set to adapt to the outdoor mode of the electronic device. In this way, the first startup window can match the current mode of the electronic device and improve the user experience. The embodiments of the present application do not limit the display content of the first startup window.
[0163] In one implementation, after step S1011, steps S1013 - S1014 are further included.
[0164] Step S1013, when the first application does not enable the startup window function, determine whether the first application can add the first startup window.
[0165] When the first application does not enable the startup window function, it may be that the developer has disabled the startup window function for various considerations, and it does not necessarily mean that the first application itself does not have the startup window function. Since disabling the startup window function will make users feel that the cold start process of the first application has a slow response speed and is not smooth, it is necessary to determine whether the first application can add a startup window.
[0166] If the first application itself has the startup window function and the function is easy to enable, then simply re-enable the function. If the first application itself does not have the startup window function, a third-party tool that matches the first application can be used to add a startup window to the first application. It is also possible to add a startup window to the first application through tools provided by the operating system. The embodiments of the present application do not limit the specific method of adding a startup window to the first application.
[0167] That is to say, in the case where the application side does not enable the startup window function, the system side can determine whether the first application can add a startup window, and in the case where the first application can add a startup window, add a startup window from multiple aspects such as the first application itself, third-party tools, or the operating system, so as to improve the response speed of the cold start process of the first application.
[0168] Step S1014, in the case where the first application can add a startup window, obtain the display content of the first startup window and create the first startup window according to the display content.
[0169] The specific implementation method of step S1014 can refer to step S1012. The embodiments of the present application will not elaborate on this.
[0170] During the first life cycle, after creating the startup window, the startup window attached to the upper layer of the first Activity is displayed.
[0171] In one implementation, in the case where the first application cannot add a startup window, after the first application calls the life cycle of the first Activity and the life cycle of the second Activity when there is no startup window, the application interface is displayed.
[0172] Step S102, after the first life cycle ends, when the first application starts and the second Activity is visible, migrate the first startup window to the second Activity, and during the process of migrating the startup window, determine whether the second Activity is in an invisible second task stack.
[0173] Among them, the second task stack is associated with the second Activity.
[0174] The first Activity and the second Activity are usually declared sequentially in the manifest file of the first application. After the end of the first life cycle of the first Activity, it will automatically jump to the second Activity and enter the second life cycle of the second Activity.
[0175] The second Activity is the second Activity set within the first application. In the following embodiments of this application, the second Activity is used as the public starting activity with visibility for exemplary illustration, and the specific type of the second Activity is not limited in the embodiments of this application.
[0176] Since the first life cycle of the first Activity ends, the operating system will destroy or suspend this Activity to release resources, and the starting window has not yet displayed its interface. Therefore, it is necessary to migrate the starting window attached to the first Activity to the second Activity so that the starting window is displayed based on the second Activity.
[0177] During this process, it is necessary to determine whether the second Activity is located in an invisible second task stack.
[0178] Among them, after the end of the first life cycle of the first Activity, the first task stack is not necessarily destroyed immediately. Although the second Activity is usually located in the second task stack associated with it, if the second Activity is specially set, the second Activity can also be located in the first task stack.
[0179] It should be noted here that the destruction of the task stack depends not only on the life cycle of the Activity, but also on factors such as the memory management strategy of the operating system, the starting mode set by the developer, and the affinity of the task stack. That is to say, when the first task stack is not destroyed, the second Activity has two situations: being located in the first task stack and being located in the second task stack.
[0180] It should be noted here that the first task stack and the second task stack can refer to the introduction of the task stack where the pre-starting activity is located and the task stack where the public starting activity is located in the foregoing content. This application will not elaborate on this.
[0181] Step S103, in the case where the second Activity is located in the second task stack, cancel the migration of the first starting window, so that the first starting window retains the use of the first task stack, where the first starting window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration.
[0182] When the second Activity is located in the second task stack, since the layer created by the second Activity and the layer created by the second task stack are asynchronous (refer to the foregoing content), and this asynchrony cannot be eliminated, then canceling the migration of the first startup window will not cause the problem of the first startup window becoming invisible due to the invisibility of the second task stack.
[0183] By delaying the first startup window in the first task stack, the user can feel that the first application is continuously in the cold start process, and the user will not feel that the cold start response is slow. At the same time, the first startup window does not migrate across task stacks, and there will be no problem of flashing screen.
[0184] Among them, the delay method of the first startup window can be to repeatedly play the same animation effect. The embodiments of the present application do not limit the delay method of the first startup window.
[0185] Step S104, when the second startup window is generated by the second Activity and the second task stack and the second startup window is sent for display, destroy the first startup window and display the second startup window.
[0186] In one implementation manner, after the end of the first life cycle, when the second Activity visible at the startup of the first application is launched, it further includes: creating a first layer corresponding to the second startup window based on the second Activity, and processing the first layer to send the processed first layer to SurfaceFlinger.
[0187] Specifically, after launching the second Activity in step S102, the second Activity will create a first layer corresponding to the second startup window, and the system service of the electronic device will add the first layer to SystemUI so that SystemUI immediately processes the first layer, calculates the size of the first layer, and updates the drawing state of the first layer. After calculating the size of the first layer and updating the drawing state of the first layer, send the first layer to SurfaceFlinger.
[0188] In one implementation manner, step S104 further includes steps S1041 - S1043.
[0189] Step S1041, create a second layer corresponding to the second startup window based on the second task stack, and process the second layer to send the processed second layer to SurfaceFlinger.
[0190] Specifically, the processing method for the second layer includes: calculating the size of the second layer and updating the drawing state of the second layer. After calculating the size of the second layer and updating the drawing state of the second layer, the second layer is sent to SurfaceFlinger.
[0191] The second layer created based on the second task stack has a lag relative to the first layer, but its creation process is similar, and this application will not elaborate on it.
[0192] Step S1042, after SurfaceFlinger receives the first layer and the second layer, synthesize the first layer and the second layer to generate the second startup window.
[0193] In this way, SurfaceFlinger can ensure that it has received both the first layer created by the second Activity and the second layer created by the second task stack, ensuring that the second startup window can be normally displayed.
[0194] Step S1043, send the second startup window to the display driver through SurfaceFlinger.
[0195] After determining that the second startup window can be normally displayed, it is sent for display.
[0196] That is to say, although there is still asynchrony between the first layer created by the second Activity and the second layer created by the second task stack, before the second startup window cannot be normally displayed, by delaying the display of the first startup window in the first task stack, this asynchronous process can be covered. Until the second startup window can be normally displayed, the first startup window and the second startup window are continued. In this way, the splash screen problem is avoided.
[0197] In one implementation, after step S102, step S105 is further included.
[0198] Step S105, when the second Activity is not in the second task stack, complete the migration of the startup window in the first task stack and display the first startup window attached to the upper layer of the second Activity based on the first task stack.
[0199] In some cases, when the second Activity is started, the corresponding second task stack is not created, but is started in the first task stack. Since the first task stack is visible, the second Activity is visible, and the first startup window is visible, there will be no splash screen problem.
[0200] It should be noted here that although the embodiments of the present application are directed to a scenario where two or more Activities for cold start are set within a first application, at least one of the frontmost Activities is an invisible Activity, and the invisible Activity and the visible Activity are set in different task stacks, it is also possible to be compatible with a scenario where the invisible Activity and the visible Activity are set in the same task stack.
[0201] In one implementation, after step S104, step S106 is further included.
[0202] Step S106, when a preset condition is met, switch from displaying a startup window to displaying an application interface corresponding to the first application, where the preset condition includes: the application interface is drawn completely or at least a part of the interface element data in the application interface is drawn, and the interface element data includes at least one of a title bar and a navigation bar in the application interface.
[0203] In this way, the first application completes the cold start process and enters the application interface.
[0204] The application program startup method shown in this embodiment, for the situation where two or more activity components are started during the cold start of the application program and the first activity component is invisible, changes the migration logic of the startup window, so that the startup window migrates within the same task stack and does not migrate across task stacks. In this way, the response speed of the application program during the cold start process can be fast, and the splash screen problem can be avoided.
[0205] Figure 9 It is the third flowchart of an application program startup method provided by the embodiments of the present application.
[0206] As Figure 9 shown, in some other embodiments, the method may further include the following steps S201 - S203.
[0207] Step S201, based on the user's cold start operation on the first application, when the first application starts at least one invisible first Activity, within the first life cycle corresponding to the first Activity, display a third startup window attached to the upper layer of the first Activity.
[0208] Among them, the first Activity is located in the visible first task stack, and the first task stack is associated with the first Activity.
[0209] The specific implementation manner of step S201 can refer to step S101, and the embodiments of the present application will not elaborate on this.
[0210] In one implementation, step S201 includes steps S2011 - S2012.
[0211] Step S2011, determine whether the first application has enabled the startup window function.
[0212] Step S2012, when the first application has enabled the startup window function, obtain the display content of the third startup window, and create the third startup window according to the display content.
[0213] In one implementation, after step S2011, steps S2013 - S2014 are further included.
[0214] Step S2013, when the first application has not enabled the startup window function, determine whether the first application can add a startup window.
[0215] Step S2014, when the first application can add a startup window, obtain the display content of the startup window, and create the startup window according to the display content.
[0216] For the specific implementation processes of the above steps S2011 - S2014, reference can be made to steps S1011 - S1014 in the foregoing embodiments, and the embodiments of the present application will not elaborate on this.
[0217] Step S202, after the end of the first life cycle, when starting the visible second Activity of the first application, migrate the third startup window to the second Activity, and during the process of migrating the third startup window, preset the layer attribute of the second task stack associated with the second Activity to visible.
[0218] Specifically, it can be achieved by setting the program code for representing the layer attribute corresponding to the second task stack to "True", so as to preset the layer attribute of the second task stack to visible. Among them, the coding methods of different operating systems may be different, and the embodiments of the present application do not limit the specific method of changing the layer attribute code.
[0219] It should be noted here that the initial program code of the second task stack usually sets its layer attribute to invisible. By changing its initial program code in advance to preset the layer attribute of the second task stack to visible, the third startup window attached thereto is visible. Therefore, there will be no flash screen during the process of migrating the third startup window in the second task stack.
[0220] Step S203, complete the migration of the startup window in the second task stack, and display the startup window attached to the second Activity based on the second task stack.
[0221] In one implementation, after step S203, step S204 is further included.
[0222] Step S204, when a preset condition is satisfied, switch from displaying a startup window to displaying an application interface corresponding to a first application, where the preset condition includes: the application interface is drawn completely or at least a part of the interface element data in the application interface is drawn completely, and the interface element data includes at least one of a title bar and a navigation bar in the application interface.
[0223] In this way, the first application completes the cold start process and enters the application interface.
[0224] In the application program startup method shown in the embodiments of the present application, for the situation where two or more activity components are started during the cold start process of the application program and the first activity component is invisible, while maintaining the migration logic of the startup window, the attribute of the second task stack is changed, and its invisibility is pre-changed, so that the second activity component is started in the second task stack with visibility. In this way, the startup window can always be displayed in the second task stack, and there will be no problem that the startup window becomes invisible due to the invisibility of the task stack, and thus the splash screen problem will not occur. It can make the response speed of the application program cold start process fast and avoid the splash screen.
[0225] Figure 10 It is a schematic diagram of an application program startup device provided by an embodiment of the present application.
[0226] As Figure 10 shown, in some embodiments, the electronic device can implement corresponding functions through a software device as Figure 10 shown. The application program startup device 200 may include:
[0227] A first display module 201, which is configured to, based on a cold start operation of a user on a first application, when the first application starts at least one invisible first Activity, display a first startup window attached to the upper layer of the first Activity within the first life cycle corresponding to the first Activity, where the first Activity is located in a visible first task stack, and the first task stack is associated with the first Activity.
[0228] A first migration module 202, which is configured to, after the first life cycle ends, when the first application starts a visible second Activity, migrate the first startup window to the second Activity, and during the process of migrating the first startup window, determine whether the second Activity is located in an invisible second task stack, and the second task stack is associated with the second Activity.
[0229] The first cancellation module 203 is configured to cancel the migration of the first startup window when the second Activity is located in the second task stack, so that the first startup window retains the use of the first task stack. The first startup window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration.
[0230] The second display module 204 is configured to destroy the first startup window and display the second startup window when the second startup window is generated by the second Activity and the second task stack and sent for display.
[0231] The application startup device 200 shown in the embodiments of the present application changes the migration logic of the startup window for the case where two or more activity components are started during the cold startup process of the application and the first activity component is invisible, so that the startup window migrates within the same task stack instead of across task stacks. In this way, the response speed of the application cold startup process can be fast, and the splash screen problem can be avoided.
[0232] Figure 11 It is a schematic diagram of an application startup device provided by another embodiment of the present application.
[0233] As Figure 11 shown, in some other embodiments, the electronic device can implement the corresponding functions through a software device as Figure 11 shown. The application startup device 300 may include:
[0234] The third display module 301 is configured to, based on the user's cold startup operation on the first application, display a third startup window attached to the upper layer of the first Activity during the first life cycle of the first Activity when the first application starts at least one invisible first Activity. The first Activity is located in a visible first task stack, and the first task stack is associated with the first Activity.
[0235] The second migration module 302 is configured to, after the end of the first life cycle, when the first application starts a visible second Activity, migrate the third startup window to the second Activity, and during the process of migrating the third startup window, preset the layer attribute of the second task stack associated with the second Activity to be visible.
[0236] The fourth display module 303 is configured to complete the migration of the third startup window in the second task stack and display the third startup window based on the visible second task stack.
[0237] The application startup device 300 shown in the embodiments of the present application, in the case of starting two or more active components during the cold startup process of the application and the first active component being invisible, while maintaining the migration logic of the startup window, changes the attributes of the second task stack, pre-changes its invisibility, and enables the second Activity to start in the second task stack with visibility. In this way, the startup window can always be displayed in the second task stack, and the problem of the startup window being invisible due to the invisibility of the task stack, and thus the resulting splash screen problem, can be avoided. The cold startup process of the application can have a fast response speed and avoid the splash screen.
[0238] Figure 12 It is a schematic structural diagram of an application startup device provided by the embodiments of the present application.
[0239] As Figure 12 shown, in one embodiment, the electronic device can implement corresponding functions through the Figure 12 hardware device shown. The device may include: a touch screen 401, a memory 402, a processor 403, and a communication module 404. The above components can be connected through one or more communication buses 405. The touch screen 401 may include a display panel 4011 and a touch sensor 4012. Among them, the display panel 4011 is used to display images, and the touch sensor 4012 can transmit the detected touch operation to the application processor 403 to determine the touch event type and provide a visual output related to the touch operation through the display panel 4011. The processor 403 may include one or more processing units. For example, the processor 403 may include an application processor, a modem processor, a graphics processor, an image signal processor, a controller, a video codec, a digital signal processor, a baseband processor, and / or a neural network processor, etc. Among them, different processing units may be independent devices or integrated in one or more processors. The memory 402 is coupled to the processor 403 and is used to store various software programs and / or computer instructions. The memory 402 may include volatile memory and / or non-volatile memory. When the processor executes the computer instructions, the electronic device can execute each function or step of the above method embodiments.
[0240] When the software program and / or multiple sets of instructions in the memory 402 are executed by the processor 403, the electronic device is enabled to implement the following method steps: Based on the user's cold start operation on the first application, when the first application starts at least one invisible first Activity, within the first life cycle corresponding to the first Activity, a first startup window attached to the upper layer of the first Activity is displayed, where the first Activity is located in the visible first task stack, and the first task stack is associated with the first Activity; after the first life cycle ends, when the first application starts a visible second Activity, the first startup window is migrated to the second Activity, and during the process of migrating the first startup window, it is determined whether the second Activity is located in an invisible second task stack, and the second task stack is associated with the second Activity; when the second Activity is located in the second task stack, the migration of the first startup window is cancelled, and the first startup window is retained for use with the first task stack, where the first startup window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration; when a second startup window is generated for the second Activity and the second task stack and the second startup window is sent for display, the first startup window is destroyed and the second startup window is displayed.
[0241] In some other embodiments, based on the same hardware device, when the software program and / or multiple sets of instructions in the memory 402 are executed by the processor 403, the electronic device can also implement the following method steps: Based on the user's cold start operation on the first application, when the first application starts at least one invisible first Activity, within the first life cycle corresponding to the first Activity, a third startup window attached to the upper layer of the first Activity is displayed, where the first Activity is located in the visible first task stack, and the first task stack is associated with the first Activity; after the first life cycle ends, when the first application starts a visible second Activity, the third startup window is migrated to the second Activity, and during the process of migrating the third startup window, the layer attribute of the second task stack associated with the second Activity is preset to be visible; the migration of the third startup window is completed in the second task stack, and the third startup window is displayed based on the visible second task stack.
[0242] The present application also provides an electronic device, including: a processor, a memory, and a touch screen; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device is enabled to execute the application program startup method in any one of the implementation manners in the above embodiments.
[0243] The embodiments of the present application further provide a chip system, which includes at least one processor and at least one interface circuit. The processor and the interface circuit can be interconnected by a line. For example, the interface circuit can be used to receive signals from other devices (such as the memory of an electronic device). For another example, the interface circuit can be used to send signals to other devices. Exemplarily, the interface circuit can read the instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can execute each step in the above embodiments. Of course, the chip system can also include other discrete devices, and the embodiments of the present application do not make specific limitations on this.
[0244] The embodiments of the present application further provide a computer-readable storage medium, which includes computer instructions. When the computer instructions run on the above electronic device, the electronic device is enabled to execute each function or step executed in the above method embodiments.
[0245] The embodiments of the present application further provide a computer program product. When the computer program product runs on a computer, the computer is enabled to execute each function or step executed in the above method embodiments.
[0246] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above function modules is used as an example. In actual applications, the above functions can be allocated to different function modules according to needs, that is, the internal structure of the device is divided into different function modules to complete all or part of the functions described above.
[0247] In the several embodiments provided by the present application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.
[0248] The units described as separate components may or may not be physically separated. The components displayed as units may be a physical unit or multiple physical units, that is, they can be located in one place, or they can be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0249] In addition, in each embodiment of the present application, each functional unit can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0250] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.
[0251] The above specific embodiments further elaborate on the purpose, technical solution, and beneficial effects of the present application. It should be understood that the above are only the specific embodiments of the present application and are not used to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present application shall be included in the protection scope of the present application.< / activity>
Claims
1. An application startup method, characterized in that, Including: Based on the user's cold start operation of the first application, when at least one invisible first activity component is started in the first application, within the first life cycle corresponding to the first activity component, a first startup window attached to the upper layer of the first activity component is displayed, where the first activity component is located in a visible first task stack, and the first task stack is associated with the first activity component; After the end of the first life cycle, when the first application starts a visible second activity component, the first startup window is migrated to the second activity component, and during the process of migrating the first startup window, it is determined whether the second activity component is located in an invisible second task stack, and the second task stack is associated with the second activity component; When the second activity component is located in the second task stack, the migration of the first startup window is cancelled, so that the first startup window continues to use the first task stack, where the first startup window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration; When the second activity component and the second task stack generate a second startup window and send the second startup window to be displayed, the first startup window is destroyed and the second startup window is displayed.
2. The application startup method according to claim 1, characterized in that, Also including: When the second activity component is not located in the second task stack, the migration of the first startup window is completed in the first task stack, and the first startup window attached to the upper layer of the second activity component is displayed based on the first task stack.
3. The application startup method according to claim 1 or 2, characterized in that, Before displaying the first startup window attached to the upper layer of the first activity component, it also includes: Determining whether the first application enables the startup window function; When the first application enables the startup window function, obtaining the display content of the first startup window and creating the first startup window according to the display content.
4. The application startup method according to claim 3, characterized in that, After determining whether the first application enables the startup window function, it also includes: When the first application does not enable the startup window function, determining whether the first application can add the first startup window; When the first application can add the first startup window, obtaining the display content of the first startup window and creating the first startup window according to the display content.
5. The application startup method according to claim 4, characterized in that, After the end of the first life cycle, when the first application starts a visible second activity component, it also includes: Creating a first layer corresponding to the second startup window based on the second activity component, processing the first layer, and sending the processed first layer to the SurfaceFlinger.
6. The application startup method according to claim 5, characterized in that, The second activity component and the second task stack generate a second startup window and send the second startup window to be displayed, including: Creating a second layer corresponding to the second startup window based on the second task stack, processing the second layer, and sending the processed second layer to the SurfaceFlinger; After the SurfaceFlinger receives the first layer and the second layer, it synthesizes the first layer and the second layer to generate the second startup window; The SurfaceFlinger sends the second startup window to the display driver.
7. The application startup method according to claim 6, characterized in that, The creating the second layer corresponding to the second startup window based on the second task stack and processing the second layer to send the processed second layer to the SurfaceFlinger includes: Calculating the size of the second layer and updating the drawing state of the second layer; After calculating the size of the second layer and updating the drawing state of the second layer, sending the second layer to the SurfaceFlinger.
8. The application startup method according to claim 1, characterized in that, After displaying the second startup window, it further includes: When a preset condition is met, switching from displaying the second startup window to displaying the application interface corresponding to the first application, where the preset condition includes: the application interface is drawn or at least a part of the interface element data in the application interface is drawn, and the interface element data includes at least one of a title bar and a navigation bar in the application interface.
9. An application startup method, characterized in that, It includes: Based on the cold start operation of the user on the first application, when the first application starts at least one invisible first activity component, within the first life cycle corresponding to the first activity component, displaying a third startup window attached to the upper layer of the first activity component, where the first activity component is located in a visible first task stack, and the first task stack is associated with the first activity component; After the first life cycle ends, when the first application starts a visible second activity component, migrating the third startup window to the second activity component, and during the process of migrating the third startup window, presetting the layer attribute of the second task stack associated with the second activity component to be visible; Completing the migration of the third startup window in the second task stack and displaying the third startup window based on the visible second task stack.
10. The application startup method according to claim 9, characterized in that, Before displaying the third startup window attached to the upper layer of the first activity component, it further includes: Determining whether the first application enables the startup window function; When the first application enables the startup window function, obtaining the display content of the third startup window and creating the third startup window according to the display content.
11. The application program startup method according to claim 10, wherein, After determining whether the first application enables the startup window function, it further includes: When the first application does not enable the startup window function, determining whether the first application can add the third startup window; When the first application can add the third startup window, obtaining the display content of the third startup window and creating the third startup window according to the display content.
12. The application program startup method according to claim 11, wherein, After displaying the third startup window based on the visible second task stack, it further includes: When a preset condition is satisfied, the display switches from the third startup window to the application interface corresponding to the first application, where the preset condition includes: the application interface is drawn completely or at least a part of the interface element data in the application interface is drawn completely, and the interface element data includes at least one of a title bar and a navigation bar in the application interface.
13. An electronic device, wherein, including: a processor and a memory, wherein program instructions are stored in the memory, and when the program instructions are executed by the processor, the electronic device executes the application program startup method according to any one of claims 1-12.
14. A computer-readable storage medium, wherein, Instructions are stored in the computer-readable storage medium, and when the instructions run on the electronic device, the electronic device executes the application program startup method according to any one of claims 1-12.
15. A computer program product, wherein, When the computer program product runs on the electronic device, the electronic device executes the application program startup method according to any one of claims 1-12.