Application program starting method and electronic device
By displaying and migrating the startup window during the cold startup of the application, ensuring that the startup window is migrated in the same task stack, it solves the problem of slow response speed and splash screen during the cold startup of the application, and achieves fast response and excellent user experience.
Patent Information
- Application Number
- PCT/CN2024/112496
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-08
- Filing Date
- 2024-08-15
- Publication Date
- 2025-06-12
AI Technical Summary
During cold startup of the application, when two or more active components are started, it may cause slow response and splash screen problems.
By displaying the startup window attached to the upper layer of the active component during the application's cold startup process and migrating the startup window between the active components, ensure that the startup window is migrated in the same task stack and avoiding cross-task stack migration.
It realizes the fast response speed of the application cold start process, avoids the problem of splashing screens, and improves the user experience.
Smart Images

Figure CN2024112496_12062025_PF_FP_ABST
Abstract
Description
Application program startup method and electronic device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on December 8, 2023, with application number 202311682916.5 and invention name “A method for launching an application and an electronic device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of terminal technology, and in particular to an application startup method and an electronic device. Background Art
[0003] An application cold start refers to the process when a user installs or opens an application for the first time. During an application cold start, two or more activities may be launched. For example, if two activities are launched, and the first activity is invisible, the second visible activity is usually placed in a different task stack from the first.
[0004] Based on this, if you don't add a startup window to these two activities when launching them, then after users click the application icon, they will wait a long time before entering the application's startup interface, making the user feel that the application is slow to respond and the startup is not smooth. If you add a startup window to these two activities when launching them, because the layer of the second activity and the layer of its corresponding task stack are created asynchronously, there is a certain probability that the screen will flash when the user clicks the application icon.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide an application startup method and an electronic device, which can solve problems such as slow response speed and screen flickering during the cold startup of an application.
[0007] In a first aspect, an embodiment of the present application provides an application startup method, comprising: based on a user's cold start operation on a first application, when the first application starts at least one invisible first active component, within a first life cycle corresponding to the first active component, displaying a first startup window attached to the upper layer of the first active component, wherein the first active component is located in a visible first task stack, and the first task stack is associated with the first active component; after the end of the first life cycle, when the first application starts a visible second active component, migrating the first startup window to the second active component, and in the process of migrating the first startup window, determining whether the second active component is located in an invisible second task stack, and the second task stack is associated with the second active component; when the second active component is located in the second task stack, canceling the migration of the first startup window, so that the first startup window retains the use of the first task stack, wherein 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 active component and the second task stack generate a second startup window, and display the second startup window, destroying the first startup window and displaying the second startup window.
[0008] The application startup method shown in the embodiment of the present application changes the migration logic of the startup window to address the situation where two or more active components are started during the cold start process of the application and the first active component is invisible, so that the startup window is migrated within the same task stack instead of migrating across task stacks. In this way, the cold start process of the application can respond quickly and the screen flashing problem can be avoided.
[0009] In one implementation, the method further includes: if the second active component is not located in the second task stack, migrating the first launch window within the first task stack and displaying the first launch window attached to the second active component based on the first task stack. This implementation ensures that the launch window migrates within the same task stack, rather than across task stacks, by determining whether the second active component is located in the second task stack. This ensures faster response times during cold startup of the application and avoids screen splashing.
[0010] In one implementation, before displaying the first launch window attached to the upper layer of the first active component, the process further includes: determining whether the first application has enabled the launch window function; if the first application has enabled the launch window function, obtaining the display content of the first launch window, and creating the first launch window based on the display content. This implementation illustrates a specific method for creating the launch window. By setting the launch window, users can quickly perceive that the application has launched, thereby improving the user experience.
[0011] In one implementation, after determining whether the first application has enabled the launch window function, the system further includes: if the first application does not have the launch window function enabled, determining whether the first application can add a first launch window; if the first application can add a first launch window, obtaining the display content of the first launch window, and creating the first launch window based on the display content. With this implementation, if the application does not have the launch window function enabled, the system can determine whether the first application can add a launch window, and if so, add the launch window. Thus, by setting the launch window, users can perceive that the application has been quickly launched, thereby improving the user experience.
[0012] In one implementation, after the first lifecycle ends, when the first application launches a visible second active component, the method further includes: creating a first layer corresponding to a second launch window based on the second active component, processing the first layer, and sending the processed first layer to a surface compositor, SurfaceFlinger. This implementation indicates that the first layer can be processed immediately when the second active component is launched. If there is asynchrony in the layer processing by the second active component and the second task stack, the first launch window can retain the first task stack, allowing the first launch window and the second launch window to continue, thereby avoiding screen flickering issues.
[0013] In one implementation, a second active component and a second task stack generate a second launch window and display the second launch window, including: creating a second layer corresponding to the second launch window based on the second task stack, processing the second layer, and sending the processed second layer to SurfaceFlinger; after SurfaceFlinger receives the first layer and the second layer, synthesizing the first layer and the second layer to generate the second launch window; and sending the second launch window to the display driver via SurfaceFlinger. In this implementation, the second task stack processes the second layer after the second active component. If there is asynchronous processing of the layer by the second active component and the second task stack, the first launch window retains the use of the first task stack, allowing the first launch window and the second launch window to continue, thus avoiding screen flickering.
[0014] In one implementation, creating a second layer corresponding to the second launch window based on the second task stack and processing the second layer to send the processed second layer to 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 SurfaceFlinger. This implementation illustrates the specific processing method of the second layer by the second task stack.
[0015] In one implementation, after displaying the second launch window, the process further includes switching from displaying the second launch window to displaying the application interface corresponding to the first application when a preset condition is met, wherein the preset condition includes the completion of drawing the application interface or the completion of drawing at least a portion of the interface element data in the application interface, where the interface element data includes at least one of a title bar and a navigation bar in the application interface. With this implementation, after the launch window ends display, the application interface can be entered, completing the cold start process of the application without screen splashing.
[0016] In the second aspect, an embodiment of the present application also provides an application startup method, including: based on a user's cold start operation on a first application, when the first application starts at least one invisible first active component, within the first life cycle corresponding to the first active component, displaying a third startup window attached to the upper layer of the first active component, wherein the first active component is located in a visible first task stack, and the first task stack is associated with the first active component; after the first life cycle ends, when the first application starts a visible second active component, migrating the third startup window to the second active component, and in the process of migrating the third startup window, preset the layer properties of the second task stack associated with the second active component to 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.
[0017] The application startup method shown in the embodiment of the present application aims at the situation where two or more active components are started during the cold start process of the application and the first active component is invisible. While maintaining the migration logic of the startup window, the properties of the second task stack are changed, and its invisibility is changed in advance so that the second active component is started in the visible second task stack. In this way, the startup window can always be displayed in the second task stack, and the problem of splash screen caused by the invisible task stack causing the startup window to be invisible will not occur. This can make the cold start process of the application respond quickly and avoid splash screen.
[0018] In one implementation, before displaying the third launch window attached to the first active component, the process further includes: determining whether the first application has enabled the launch window function; if the first application has enabled the launch window function, obtaining the display content of the third launch window, and creating the third launch window based on the display content. This implementation illustrates a specific method for creating a launch window. By setting up the launch window, users can quickly perceive that the application has launched, thereby improving the user experience.
[0019] In one implementation, after determining whether the first application has enabled the launch window function, the system further includes: if the first application does not have the launch window function enabled, determining whether the first application can add a third launch window; if the first application can add a third launch window, obtaining the display content of the third launch window, and creating the third launch window based on the display content. With this implementation, if the application does not have the launch window function enabled, the system can determine whether the first application can add a launch window, and if so, add the launch window. Thus, by setting the launch window, users can perceive that the application has been quickly launched, thereby improving the user experience.
[0020] In one implementation, after displaying the third launch window based on the visible second task stack, the method further includes: switching from displaying the third launch window to displaying the application interface corresponding to the first application when a preset condition is met, wherein the preset condition includes: completion of drawing the application interface or completion of drawing at least a portion of interface element data in the application interface, where the interface element data includes at least one of a title bar and a navigation bar in the application interface. With this implementation, after the launch window ends display, the application interface can be entered, completing the cold start process of the application without screen splashing.
[0021] In a third aspect, embodiments of the present application further provide an application launching device, comprising: a first display module, configured to, upon a user cold-starting a first application, display a first launch window attached to the first active component during a first lifecycle corresponding to the first active component when the first application launches at least one invisible first active component, wherein the first active component is located in a visible first task stack associated with the first active component; a first migration module, configured to, after the first lifecycle ends, migrate the first launch window to a second active component when the first application launches a visible second active component, and during the migration of the first launch window, determine whether the second active component is located in an invisible second task stack associated with the second active component; a first cancellation module, configured to cancel the migration of the first launch window when the second active component is located in a second task stack, thereby allowing the first launch window to retain the first task stack; wherein the first launch window has a delay duration in the first task stack, and the first task stack is kept alive based on the delay duration; and a second display module, configured to, upon generating a second launch window based on the second active component and the second task stack and displaying the second launch window, destroy the first launch window and display the second launch window.
[0022] The application startup device shown in the embodiment of the present application changes the migration logic of the startup window to address the situation where two or more active components are started during the cold start process of the application and the first active component is invisible, so that the startup window is migrated within the same task stack instead of migrating across task stacks. In this way, the cold start process of the application can respond quickly and the screen flashing problem can be avoided.
[0023] In a fourth aspect, an embodiment of the present application also provides an application startup device, comprising: a third display module, the third display module is used to display a third startup window attached to the upper layer of the first active component within the first life cycle corresponding to the first active component, based on the user's cold start operation on the first application, when the first application starts at least one invisible first active component, wherein the first active component is located in a visible first task stack, and the first task stack is associated with the first active component. A second migration module, the second migration module is used to migrate the third startup window to the second active component after the first life cycle ends, when the first application starts a visible second active component, and in the process of migrating the third startup window, preset the layer properties of the second task stack associated with the second active component to visible. A fourth display module, the fourth display module is used 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.
[0024] The application startup device shown in the embodiment of the present application aims at starting two or more active components during the cold start process of the application and the first active component is invisible. While maintaining the migration logic of the startup window, the properties of the second task stack are changed, and its invisibility is changed in advance so that the second active component is started in the visible second task stack. In this way, the startup window can always be displayed in the second task stack, and the problem of splash screen caused by the invisible task stack causing the startup window to be invisible will not occur. This can make the cold start process of the application respond quickly and avoid splash screen.
[0025] In the fifth aspect, an embodiment of the present application also provides an electronic device, comprising: a processor and a memory, wherein program instructions are stored in the memory. When the program instructions are executed by the processor, the electronic device executes the application startup method as in the above-mentioned first aspect and any implementation thereof or the above-mentioned second aspect and any implementation thereof.
[0026] In a sixth aspect, an embodiment of the present application also provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on an electronic device, the electronic device executes an application startup method as in the first aspect and any implementation thereof or as in the second aspect and any implementation thereof.
[0027] In the seventh aspect, an embodiment of the present application also provides a computer program product, which, when running on an electronic device, enables the electronic device to execute an application startup method as in the first aspect and any implementation thereof or as in the second aspect and any implementation thereof.
[0028] It can be understood that 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 that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] FIG1 is a flow chart of a cold start method of application A;
[0030] FIG2 is a first schematic diagram of a cold start scenario of application A;
[0031] Figure 3 is a diagram showing the visibility relationship between active components and task stacks;
[0032] FIG4 is a second schematic diagram of a cold start scenario of application A;
[0033] FIG5 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0034] FIG6 is a schematic diagram of the software structure of the electronic device provided in an embodiment of the present application;
[0035] FIG7 is a first flow chart of a method for starting an application program provided in an embodiment of the present application;
[0036] FIG8 is a second flow chart of a method for starting an application program provided in an embodiment of the present application;
[0037] FIG9 is a third flow chart of a method for starting an application program provided in an embodiment of the present application;
[0038] FIG10 is a schematic diagram of an application startup device provided in an embodiment of the present application;
[0039] FIG11 is a schematic diagram of an application startup device provided by another embodiment of the present application;
[0040] FIG12 is a schematic structural diagram of an application startup device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The following will clearly describe the technical solutions of the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of the present application, other embodiments obtained by ordinary technicians in this field without making any creative work are all within the scope of protection of this application.
[0042] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "a plurality" means two or more. Words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not limit them to be necessarily different.
[0043] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0044] The following first describes the application scenarios of the embodiments of the present application.
[0045] Electronic devices typically have multiple applications (apps) installed. An application cold start refers to the process when a user installs or opens an application for the first time. During an application cold start, the application needs to perform a series of initialization operations, including loading resources, setting up the environment, and preheating the cache.
[0046] An activity is one of the four major components in Android. It represents the user interface and contains various UI elements, such as buttons, text boxes, and images. Activities manage the lifecycle and state transitions of users interacting with an application. Each activity has its own lifecycle, including creation, starting, pausing, resuming, stopping, and destruction. At different stages of its lifecycle, an activity can be configured with specific actions to manage the application's behavior and state. Within an application, multiple activities can work together to form the application's overall user interface and functionality.
[0047] During the cold start of an application, two or more activities may be started.
[0048] The following example uses application A as an example, and application A starts two activities during a cold start, such as an invisible pre-start activity (PreStartActivity) and a visible public start activity (StartPublicActivity). It should be noted that the public start activity can be visible or invisible. The following examples in this application are all illustrated with the public start activity as visible, which does not mean that the activity must be visible.
[0049] FIG1 is a flow chart of a cold start method of application A. FIG.
[0050] As shown in FIG1 , after the user clicks the icon of application A, the electronic device executes the following steps S1 - S10 .
[0051] In step S1, based on a user clicking an icon, the electronic device starts an invisible Activity 1 in Application A. Application A is an application program that is not running in the background, and Activity 1 may be a pre-start activity.
[0052] A pre-launch activity is a hidden activity that is started before an application is launched. This activity can initialize the application and load resources in the background to speed up the cold start time of the application and enable the application to respond to user requests more quickly when it is actually launched.
[0053] The implementation of pre-launch activities varies from application to application.
[0054] For example, in application A, the pre-launch activity can be implemented as follows:
[0055] Declare a pre-launch activity in the manifest file of application A and set a transparent theme for the pre-launch activity to ensure that the pre-launch activity is invisible at startup. When application A launches the pre-launch activity, it can perform initialization and resource loading operations for application A, such as preloading data and establishing network connections.
[0056] Step S2: After starting Activity 1, the electronic device determines whether Application A has enabled a starting window function.
[0057] The startup window can be a preview window of the Activity, which is used to inform the user that the application has started before the application interface is displayed. The startup window is managed by the window management service (WindowManagerService), which is responsible for starting and ending the startup window.
[0058] Specifically, the Activity Manager Service decides whether the Activity's startup window needs to be displayed. If it needs to be displayed, the Activity Manager Service notifies the Window Manager Service to display a startup window for the Activity being started. After receiving the notification, the Window Manager Service creates the startup window through the window management policy class (PhoneWindowManager).
[0059] The above process can be executed only after the electronic device determines that the application has enabled the startup window function.
[0060] Specifically, the electronic device can determine whether application A has enabled the startup window function in the following manner.
[0061] For example, after launching the pre-launch activity, the electronic device can detect whether application A has a flag bit B corresponding to the launch window, and determine whether a layout file is specified as the launch window background based on flag bit B. If the specified layout file exists, it is determined that application A has enabled the launch window function. In fact, the electronic device can also determine whether application A has enabled the launch window function through other methods, which are not described in detail in this application. Application A faces some problems both when the launch window function is enabled and when it is not enabled.
[0062] The following specifically describes the case where the startup window function is not enabled for application A.
[0063] In the case that the application A does not enable the startup window function, the electronic device may execute step S3.
[0064] In step S3, when the startup window function is not enabled for application A, the electronic device sequentially calls the life cycle of Activity 1 and the life cycle of Activity 2. Activity 2 may be a visible public startup activity.
[0065] FIG2 is a first schematic diagram of a cold start scenario of application A. FIG.
[0066] As shown in Figure 2, during application development, developers may disable the launch window feature for various reasons (for example, the initial launch window style is simple, or the application provider needs to place advertisements on the launch interface). Therefore, if the electronic device determines that the application does not have the launch window feature enabled, the activity management service will not send a notification to the window management service. The application will then display the application interface after calling and completing the two activities without a launch window.
[0067] For example, after the user clicks 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 cycle of Activity1 and the life cycle of Activity2, the first interface 102 is displayed.
[0068] Therefore, after the user clicks icon 101, the electronic device needs to go through a longer life cycle of calling Activity1 and the life cycle of Activity2 to complete page loading, and during this process, the user's vision always stays on the desktop of the electronic device. In this way, after the user clicks icon 101, the electronic device takes a long time to jump to the first interface 102, causing the user to feel that the startup of application A does not keep up with the hand, and the page jump is slow, affecting the user's experience.
[0069] The following specifically describes the case where application A has the startup window function enabled.
[0070] In the case that the application A enables the start window function, the electronic device may perform steps S4-S10.
[0071] Step S4: When the application A enables the startup window function, the electronic device obtains the display content of the startup window and creates a startup window according to the display content.
[0072] Step S5: During the life cycle of Activity1, the electronic device displays a startup window attached to the upper layer of Activity1.
[0073] Each application typically has one or more corresponding task stacks. The task stack is a mechanism used to manage activities in the Android system. It is a last-in, first-out (LIFO) data structure that tracks the order and status of each activity in an application. Activities with different task attributes are usually assigned to different task stacks.
[0074] When an application starts, the first activity launched is created and added to the top of the task stack. Subsequent activities are added to the task stack in the order they were launched. This allows the task stack to 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 can run simultaneously, allowing each task stack to independently handle different tasks.
[0075] The visibility of the startup window and Activity is closely related to the task stack.
[0076] Figure 3 is a diagram showing the visibility relationship between active components and task stacks.
[0077] As shown in Figure 3, based on the aforementioned task stack management relationship for activities, if the task stack is set to invisible, all activities within it are invisible. Only when the task stack is set to visible will the activities become visible. If the layers created by the activity itself are invisible, the user will not be able to see any of them, even if the task stack is set to visible.
[0078] Correspondingly, the visibility of the startup window depends on the visibility of the task stack. If the task stack is invisible, the startup window attached to it is invisible. If the task stack is visible, the startup window attached to it is visible.
[0079] 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, it is necessary to add a startup window for 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 startup window is visible. In this way, users can avoid feeling that the cold start process of application A responds too slowly.
[0080] The electronic device may display a startup window attached to the upper layer of the pre-boot activity during the life cycle of the pre-boot activity.
[0081] Step S6: After the life cycle of Activity1 ends, the electronic device starts the visible Activity2 in Application A.
[0082] When Activity2 is a visible public launch activity, after the electronic device starts the public launch activity, the public launch activity will create a layer (Surface) L1 corresponding to the launch window, and the electronic device's system service (System_server) will add SurfaceL1 to the system user interface (SystemUI) so that SystemUI can immediately process SurfaceL1, calculate the layer size of SurfaceL1 and update the layer drawing status of SurfaceL1. In this way, the public launch activity will immediately send SurfaceL1 to the surface compositor (SurfaceFlinger) to display SurfaceL1.
[0083] Step S7: The electronic device migrates the startup window to the public startup activity.
[0084] When the pre-launch activity is invisible and the public launch activity is visible, Android's native mechanism will inevitably trigger the migration of the launch window from the pre-launch activity to the public launch activity. This is because when there is at least one invisible activity with a launch window attached to it, Android's native mechanism ensures that the launch window migrates sequentially on these invisible activities until it migrates to the first visible activity to avoid screen splashing.
[0085] It should be noted that pre-launch activities and public launch activities are located in different task stacks. Pre-launch activities are internal activities that usually do not need to interact with users or other applications. Therefore, pre-launch activities can be set in a separate task stack to separate them from the main application task stack for better management and control of the activities within. At the same time, it can also ensure that the pre-launch activities are not occupied by other applications.
[0086] The public launch activity is used to respond to external trigger events and may need to interact with the user or other applications. Therefore, the public launch activity can be set in the main application task stack to facilitate users to navigate and interact within the application.
[0087] The process of migrating the startup window of an electronic device involves not only transferring the startup window between the pre-startup activity and the common startup activity, but also switching the task stack. Specifically, after the common startup activity starts, the operating system determines the task stack to which the common startup activity belongs and switches from the task stack where the pre-startup activity is located to the task stack where the common startup activity is located.
[0088] The initial attribute of the task stack of the public startup activity is usually invisible by default. Therefore, the startup window migrated to the task stack is invisible at this time.
[0089] In step S8 , the electronic device calculates the layer size of the migrated startup window and updates the layer drawing state of the startup window.
[0090] SurfaceL2 becomes visible only after the task stack layer SurfaceL2 corresponding to the public startup activity is sent to SurfaceFlinger. At this time, when both SurfaceL1 and SurfaceL2 are visible, the startup window can display dynamic effects.
[0091] Specifically, the Surface in an Activity is different from the Surface in the task stack. In an Activity, you can set a layout file or create a view hierarchy using code to determine the UI display. Each view can be considered a Surface, and surfaces are stacked in the order they are added, with the last view added at the top. The Surface in an Activity is used to manage the UI display.
[0092] The Surface in the task stack refers to the background stack structure used to manage Activity instances. Each time a new activity is started, it is pushed to the top of the task stack and becomes the currently active activity. Therefore, the currently active activity is at the top of the task stack, and other activities are located below it, forming a hierarchical structure. The Surface in the task stack is used to control the hierarchical relationship and navigation order of activities.
[0093] The Surface of the Activity and the Surface in the task stack have different functions and appear in different orders. The Surface of the Activity is created and displayed during the life cycle of the Activity, while the Surface in the task stack is managed and displayed according to the startup order of the Activity.
[0094] That is to say, the layers in the task stack lag behind the layers in the Activity.
[0095] Accordingly, the display of SurfaceL1 and SurfaceL2 is asynchronous. SurfaceL1 is displayed before SurfaceL2 in step S6, and SurfaceL2 is displayed in step S8, thus causing a flickering screen.
[0096] FIG4 is a second schematic diagram of a cold start scenario of application A. ...
[0097] As shown in Figure 4, 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 add the pending transaction to SystemUI so that SystemUI can process SurfaceL2, calculate the layer size of SurfaceL2 and update the layer drawing status of SurfaceL2. The public startup activity will send SurfaceL2 to SurfaceFlinger to display SurfaceL2.
[0098] 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.
[0099] Therefore, if SurfaceL1 and SurfaceL2 are both 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 flicker will occur.
[0100] 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, and a splash screen is likely to appear as shown in Figure 4. In other words, a splash screen is actually a probabilistic event.
[0101] Step S9: The electronic device displays a startup window within the life cycle of the public startup activity.
[0102] Step S10: After displaying the startup window, the electronic device displays the application interface corresponding to the public startup activity.
[0103] In this way, application A completes the cold start process.
[0104] During the cold start of the aforementioned application A, since the invisible Activity 1 and the visible Activity 2 are usually located in different task stacks, there is a certain probability that a screen flash problem will occur during the migration of the startup window based on these two Activities.
[0105] In order to solve the above problems, an embodiment of the present application shows a method for starting an application program, which can be applied to an electronic device.
[0106] The application startup method provided in the embodiments of the present application can be applied to electronic devices with display functions. Among them, electronic devices include but are not limited to mobile phones, tablets, personal computers, workstations, large-screen devices (such as smart screens and smart TVs), wearable devices (such as smart bracelets and smart watches), handheld game consoles, home game consoles, virtual reality devices, augmented reality devices, mixed reality devices, etc., in-vehicle smart terminals, etc.
[0107] FIG5 is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application.
[0108] As shown in FIG5 , 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. The sensor module 150 may include a touch sensor 150A.
[0109] It should be understood that the structures illustrated in the embodiments of the present application do 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, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0110] 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). The different processing units may be independent devices or integrated into one or more processors.
[0111] The memory 120 can 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, an application required for at least one function (such as a sound playback function, an image playback function, etc.), 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.), 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 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 instructions stored in the memory 120, and / or instructions stored in a memory provided in the processor.
[0112] The wireless communication function of the electronic device 100 can be implemented through the antenna 10, the antenna 20, the mobile communication module 130, the wireless communication module 140, the modem processor and the baseband processor.
[0113] Antenna 10 and antenna 20 are used to transmit and receive electromagnetic wave signals.
[0114] The mobile communication module 130 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for the electronic device 100. The mobile communication module 130 can receive electromagnetic waves through the antenna 10, filter and amplify the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 130 can also amplify the signals modulated by the modem processor and convert them into electromagnetic waves for radiation via the antenna 10.
[0115] The wireless communication module 140 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 20, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 20.
[0116] Electronic device 100 implements display functionality through a GPU, display screen 160, and an application processor. A GPU is a microprocessor for image processing that connects display screen 160 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0117] Display screen 160 is used to display images, videos, and the like. Display screen 160 includes a display panel. The display panel can be 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, or a quantum dot light-emitting diode (QLED).
[0118] Touch sensor 150A, also known as a "touch device," can be disposed on display screen 160. Touch sensor 150A and display screen 160 form a touch screen, also known as a "touch screen." Touch sensor 150A is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to an application processor to determine the type of touch event. Visual output related to the touch operations can be provided via display screen 160. In other embodiments, touch sensor 150A can also be disposed on the surface of electronic device 100, at a location different from that of display screen 160.
[0119] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present application, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.
[0120] FIG6 is a schematic diagram of the software structure of the electronic device provided in an embodiment of the present application.
[0121] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0122] The application layer can include a series of application packages.
[0123] As shown in FIG6 , the application package may include applications such as battery management, camera, gallery, calendar, call, map, navigation, music, video, and short message.
[0124] Each application contains one or more layers. Each application performs layer rendering (Render) operations independently according to its own application design and sends all drawn layers to the surface compositor (SurfaceFlinger) in the system library. The application can send a layer to SurfaceFlinger when it is finished drawing it, or send the drawn layer to SurfaceFlinger when it finishes drawing the first part of the set interface element data in a layer.
[0125] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0126] As shown in FIG6 , the application framework layer may include a window manager, an input manager, a sensor manager, a telephony manager, a resource manager, a notification manager, and the like.
[0127] The input manager can be used to monitor user input events, such as click events and slide events performed by the 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.
[0128] The sensor manager is used to monitor the data returned by various sensors in the electronic device, such as motion sensor data, proximity sensor data, temperature sensor data, etc. Using the data returned by each sensor, the electronic device can determine whether it is shaking or whether the display screen 160 is blocked.
[0129] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
[0130] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.
[0131] All layers in the application framework layer (including visible and invisible layers) form a layer list, defined as the ListAll. The surface compositor selects visible layers from ListAll to form the visible layer list, defined as the DisplayList. The surface compositor then selects an idle frame buffer from one of three reusable frame buffers and performs a compositing operation on that frame buffer based on the application configuration. The application configuration may specify which layer is placed at the bottom, which layer is placed at the top, which area is visible, and which area is transparent. Based on the compositing operation, the frame buffer overlays the layers in the DisplayList to produce the final display image. The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files in the application and application framework layers as binary files. The virtual machine performs 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 library, 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), SurfaceFlinger, etc.
[0132] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
[0133] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0134] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0135] A 2D graphics engine is a drawing engine for 2D drawings.
[0136] SurfaceFlinger is used to manage and synthesize the graphical interface of the application and display it on the device's display. For example, the application can provide image data to SurfaceFlinger. After SurfaceFlinger receives the layer from the application, it can put it into a queue to be processed. SurfaceFlinger can traverse the queue to be processed in a specific order and synthesize the layer according to the properties of each layer. When the layer synthesis is completed, SurfaceFlinger can send the layer to the display driver in the kernel layer.
[0137] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.
[0138] The display driver can transmit the layer transmitted by SurfaceFlinder to the display screen 160 for display.
[0139] It should be understood that the structures illustrated in the embodiments of the present application do 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, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0140] FIG7 is a first flow chart of an application startup method provided in an embodiment of the present application.
[0141] As shown in FIG. 7 , the method may include the following steps S101 - S104 .
[0142] Step S101 : Based on a user's cold start operation on a first application, when the first application starts at least one invisible first activity, a first start window attached to an upper layer of the first activity is displayed within a first life cycle corresponding to the first activity.
[0143] The first Activity is located in a visible first task stack, and the first task stack is associated with the first Activity.
[0144] The cold start operation of the first application by the user may be a click operation performed by the user on the icon corresponding to the first application through a touch screen, a mouse or a 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 click operation of the user, and may also be an operation in which the user inputs a voice through a voice assistant, or an operation in which the user inputs a preset start gesture. For example, when the user voice inputs the instruction "open the first application" is detected, it is determined that a cold start operation for the first application is detected. When a preset gesture input by the user is detected based on a sensor built into 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 embodiment of the present application does not limit the specific operation form of the cold start operation. In this way, the user interacts with the first application to trigger the startup process of the first application.
[0145] The first application is an application that is not running in the background. After the startup process of the first application is triggered, the operating system allocates the required resources and memory to the first application, starts loading the code and data of the first application, and starts the first activity set in the first application.
[0146] The embodiment of the present application is directed to a scenario in which two or more Activities for cold start are set in a first application, and at least one of the Activities in front 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 public startup 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 public startup activity, or an invisible public startup activity, and the third Activity can be a visible homepage root activity (HomeRootActivity). Among them, when there are multiple invisible Activities set in the front, the startup window attached to the Activity is visible until it is started to a visible Activity. 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, and the first one is an invisible activity and the second one is a visible activity. In fact, the present application does not limit the number of activities set in the first application.
[0147] In one implementation, upon detecting that a first flag is set in a first application, the operating system may determine that the first application will place the first invisible activity and the second visible activity in different task stacks. Based on this, the operating system determines to execute the application startup method in the embodiment of the present application in such a scenario. It should be noted that the first flag is set in different ways in different operating systems, and the embodiment of the present application does not limit the specific form of the first flag.
[0148] 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 description. The embodiments of the present application do not limit the specific type of the first Activity.
[0149] Each Activity has its own life cycle, which usually includes multiple stages such as creation, startup, running, and destruction. The specific implementation process of each life cycle depends on the developer's design process.
[0150] For example, in the first life cycle, during the creation phase of the pre-start activity, the Activity can perform initialization operations, such as setting the layout, binding views, etc. During the startup phase of the pre-start activity, the Activity can perform some preparatory work. At this time, the Activity can be in the foreground, registering listeners and startup windows, etc. During the running phase of the pre-start activity, the Activity can save temporary data or stop the running startup window. It can also release occupied resources and cancel the registration of listeners when the Activity is about to end. During the destruction phase of the pre-start activity, the Activity can perform final cleanup work, such as further releasing resources and canceling bindings.
[0151] That is, during the startup phase and the running phase of the pre-start activity, the first startup window attached to the upper layer of the Activity may be displayed.
[0152] Because the pre-launch activity is the first activity started in the first application, a task stack is typically not yet established in the first application. Instead, a separate task stack, pre-set for the pre-launch activity, is started. This is the first task stack, and the first task stack is typically set to visible. Thus, the pre-launch activity is placed in the visible first task stack.
[0153] It should be noted here that if an independent task stack is not set for the pre-start activity in advance, and there is no task stack in the first application that directly matches the pre-start activity, then if a first flag is set in the startup intent (Intent) mechanism corresponding to the first application, the first flag is, for example, FLAG_ACTIVITY_NEW_TASK, then a new task stack can be created according to the first flag, and this new task stack can also serve as the first task stack. The embodiment of the present application does not limit the specific method of creating the first task stack.
[0154] FIG8 is a second flow chart of an application startup method provided in an embodiment of the present application.
[0155] As shown in FIG8 , in one implementation, step S101 includes steps S1011 - S1012 .
[0156] Step S1011: Determine whether the first application has enabled a startup window function.
[0157] After the pre-start activity enters the first life cycle, the electronic device can detect whether the first application has a second flag bit corresponding to the startup window, and determine whether a layout file is specified as the background of the startup window based on the second flag bit. If a specified layout file exists, it is determined that the first application has enabled the startup window function.
[0158] For example, the first application is configured with a manifest file, and the manifest file is traversed to view the activities for cold start, that is, to view the pre-start activities and the public start activities, and in these activities <activity>The second flag bit is detected under the tag (the second flag bit can be, for example, a Theme tag). After detecting the Theme tag, it is determined whether the Theme tag uses the WindowBackground attribute or other related attributes to specify a layout file as the background of the launch window. In this way, it can be determined that the first application has enabled the launch window function.
[0159] When detecting a cold start operation for the first application, the electronic device may also read whether information on enabling the startup window is included in the manifest file of the first application, and determine whether the startup window function is enabled for the first application based on the read return value.
[0160] Step S1012: When the first application has enabled the startup window function, obtain the display content of the first startup window and create the first startup window according to the display content.
[0161] 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 an Android native process, which is a conventional display method of the startup window.
[0162] The display content of the first startup window may be a preset picture or animation, and the first startup window may be created according to the preset picture or animation.
[0163] Taking the display content of the first startup window as a preset picture as an example for description, the preset picture can be used as the background of the first startup window, filled in the first startup window, and the preset picture can be set with the icon of the first application.
[0164] To provide users with a better visual experience, the preset image can be set in a variety of colors, such as black and dark blue to suit the night mode of the electronic device. White and light gray to suit the outdoor mode of the electronic device can also be set. In this way, the first startup window can match the current mode of the electronic device, improving the user experience. The embodiments of the present application do not limit the display content of the first startup window.
[0165] In one implementation, after step S1011, steps S1013-S1014 are further included.
[0166] Step S1013 : When the first application does not enable the startup window function, determine whether the first application can add a first startup window.
[0167] If the first app doesn't have the launch window feature enabled, it's likely because the developer has disabled it for various reasons, not necessarily because the first app itself doesn't have a launch window. Disabling the launch window can make the user experience a slow and unresponsive cold start of the first app. Therefore, it's necessary to determine whether the first app can add a launch window.
[0168] If the first application itself has a launch window function and the function is easy to enable, then re-enable the function. If the first application itself does not have a launch window function, a launch window can be added for the first application using a third-party tool that is compatible with the first application. Alternatively, a launch window can be added for the first application using tools provided by the operating system. The embodiments of the present application do not limit the specific method for adding a launch window to the first application.
[0169] That is to say, when the startup window function is not enabled on the application side, the system side can determine whether the first application can add a startup window, and if 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 operating system to improve the response speed of the cold start process of the first application.
[0170] Step S1014 : If 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.
[0171] The specific implementation of step S1014 can refer to step S1012, which will not be described in detail in this embodiment of the present application.
[0172] In the first life cycle, after the startup window is created, the startup window attached to the upper layer of the first Activity is displayed.
[0173] In one implementation, when the first application cannot add a startup window, the first application displays the application interface after calling the life cycle of the first Activity and the life cycle of the second Activity when there is no startup window.
[0174] Step S102 , after the first lifecycle ends, when the first application starts a visible second activity, migrate the first startup window to the second activity, and during the migration of the startup window, determine whether the second activity is located in an invisible second task stack.
[0175] The second task stack is associated with the second Activity.
[0176] The first and second activities are usually declared sequentially in the manifest file of the first application. After the first lifecycle of the first activity ends, it automatically jumps to the second activity and enters the second lifecycle of the second activity.
[0177] The second activity is the second activity set in the first application. In the following embodiments of this application, the second activity is used as a public startup activity with visibility for illustrative purposes. The embodiments of this application do not limit the specific type of the second activity.
[0178] Since the first life cycle of the first Activity ends, the operating system will destroy or pause the Activity to release resources, and the startup window has not yet displayed its interface. Therefore, it is necessary to migrate the startup window attached to the first Activity to the second Activity so that the startup window is displayed based on the second Activity.
[0179] During this process, it is necessary to determine whether the second activity is located in the invisible second task stack.
[0180] After the first lifecycle of the first activity ends, the first task stack is not necessarily destroyed immediately. Although the second activity is usually located in the second task stack associated with it, it can also be located in the first task stack if special settings are made for the second activity.
[0181] It's important to note that the destruction of a task stack depends not only on the lifecycle of the activity, but also on factors such as the operating system's memory management policy, the startup mode set by the developer, and the affinity of the task stack. In other words, if the first task stack is not destroyed, the second activity can be located in either the first or the second task stack.
[0182] It should be noted that the first task stack and the second task stack can refer to the introduction of the task stack where the pre-start activity is located and the task stack where the public start activity is located in the aforementioned content. This application will not elaborate on this.
[0183] Step S103 , when the second activity is located in the second task stack, cancel the migration of the first startup window so that the first startup window retains the first task stack, wherein 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.
[0184] When the second activity is in the second task stack, the layer created by the second activity is asynchronous with the layer created by the second task stack (see the previous content), and this asynchrony cannot be eliminated. Therefore, if the migration of the first launch window is canceled, the screen splash problem caused by the invisibility of the first launch window due to the invisibility of the second task stack will not occur.
[0185] By delaying the first startup window in the first task stack, the user can feel that the first application is continuously in the cold startup process, without feeling that the cold startup response is slow. At the same time, the first startup window does not migrate across task stacks, and the screen flashing problem will not occur.
[0186] The first startup window can be delayed by repeatedly playing the same animation effect. The embodiment of the present application does not limit the delay method of the first startup window.
[0187] Step S104 : When a second startup window is generated by the second activity and the second task stack and the second startup window is displayed, the first startup window is destroyed and the second startup window is displayed.
[0188] In one implementation, after the first life cycle ends, when the first application starts a visible second Activity, it also includes: creating a first layer corresponding to the second startup window based on the second Activity, processing the first layer, and sending the processed first layer to SurfaceFlinger.
[0189] Specifically, after the second activity is started in step S102, the second activity will create a first layer corresponding to the second launch window. The electronic device's system service will add the first layer to the SystemUI so that the SystemUI will immediately process the first layer, calculate the size of the first layer, and update the drawing state of the first layer. After the size of the first layer is calculated and the drawing state of the first layer is updated, the first layer is sent to SurfaceFlinger.
[0190] In one implementation, step S104 also includes steps S1041 - S1043 .
[0191] Step S1041: Create a second layer corresponding to the second startup window based on the second task stack, process the second layer, and send the processed second layer to SurfaceFlinger.
[0192] Specifically, the second layer is processed by calculating the size of the second layer and updating the drawing state of the second layer. After the size of the second layer is calculated and the drawing state of the second layer is updated, the second layer is sent to SurfaceFlinger.
[0193] The second layer created based on the second task stack has a lag relative to the first layer, but the creation process is similar and will not be described in detail in this application.
[0194] Step S1042: After SurfaceFlinger receives the first layer and the second layer, it synthesizes the first layer and the second layer to generate a second startup window.
[0195] In this way, SurfaceFlinger can ensure that it receives 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 displayed normally.
[0196] Step S1043: Send the second startup window to the display driver through SurfaceFlinger.
[0197] After confirming that the second startup window can be displayed normally, it is displayed.
[0198] In other words, although the first layer created by the second activity and the second layer created by the second task stack are still asynchronous, by delaying the display of the first launch window in the first task stack until the second launch window can be displayed normally, this asynchronous process can be overcome. When the second launch window can be displayed normally, the first and second launch windows are connected, thus avoiding the screen splash problem.
[0199] In one implementation, after step S102, step S105 is further included.
[0200] Step S105 , when the second Activity is not located in the second task stack, the migration of the startup window is completed in the first task stack, and the first startup window attached to the upper layer of the second Activity is displayed based on the first task stack.
[0201] In some cases, when the second activity is started, the corresponding second task stack is not created, but it 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, the screen splash problem will not occur.
[0202] It should be noted here that, although the embodiment of the present application is aimed at setting two or more activities for cold start in the first application, and at least one of the front activities is an invisible activity, and the invisible activity and the visible activity are set in different task stacks, it is also compatible with the scenario where the invisible activity and the visible activity are set in the same task stack.
[0203] In one implementation, after step S104, step S106 is further included.
[0204] Step S106, when the preset conditions are met, switch from displaying the startup window to displaying the application interface corresponding to the first application, wherein the preset conditions include: 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 the title bar and navigation bar in the application interface.
[0205] In this way, the first application completes the cold start process and enters the application interface.
[0206] The application startup method shown in this embodiment changes the migration logic of the startup window to address the situation where two or more active components are started during the cold start process of the application and the first active component is invisible, so that the startup window is migrated within the same task stack instead of migrating across task stacks. In this way, the cold start process of the application can respond quickly and the screen flashing problem can be avoided.
[0207] FIG9 is a third flow chart of an application startup method provided in an embodiment of the present application.
[0208] As shown in FIG. 9 , in some other embodiments, the method may further include the following steps S201 - S203 .
[0209] Step S201: Based on a user's cold start operation on a first application, when the first application starts at least one invisible first activity, a third start window attached to an upper layer of the first activity is displayed within a first life cycle corresponding to the first activity.
[0210] The first Activity is located in a visible first task stack, and the first task stack is associated with the first Activity.
[0211] The specific implementation of step S201 can refer to step S101, which will not be described in detail in this embodiment of the present application.
[0212] In one implementation, step S201 includes steps S2011 - S2012 .
[0213] Step S2011: Determine whether the first application has enabled the startup window function.
[0214] 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.
[0215] In one implementation, after step S2011, steps S2013-S2014 are also included.
[0216] Step S2013: If the first application does not enable the startup window function, determine whether the first application can add a startup window.
[0217] Step S2014: If the first application can add a startup window, obtain the display content of the startup window and create a startup window according to the display content.
[0218] The specific implementation process of the above steps S2011-S2014 can refer to steps S1011-S1014 in the aforementioned embodiment, which will not be described in detail in the embodiment of the present application.
[0219] Step S202, after the first life cycle ends, when the first application starts a visible second activity, migrate the third launch window to the second activity, and in the process of migrating the third launch window, preset the layer attribute of the second task stack associated with the second activity to visible.
[0220] Specifically, the layer attributes of the second task stack can be preset to visible by setting the program code corresponding to the second task stack and representing the layer attributes to "True." Different operating systems may use different encoding methods, and the present embodiment does not limit the specific method of modifying the layer attribute code.
[0221] It should be noted here that the initial program code of the second task stack usually sets its layer property to invisible. If its initial program code is changed in advance so that the layer property of the second task stack is preset to visible, the third startup window attached to it will be visible. Therefore, no screen splash will occur during the migration of the third startup window in the second task stack.
[0222] Step S203: completing the migration of the startup window in the second task stack, and displaying the startup window attached to the second Activity based on the second task stack.
[0223] In one implementation, after step S203, step S204 is further included.
[0224] Step S204, when the preset conditions are met, switch from displaying the startup window to displaying the application interface corresponding to the first application, wherein the preset conditions include: 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 the title bar and navigation bar in the application interface.
[0225] In this way, the first application completes the cold start process and enters the application interface.
[0226] The application startup method shown in the embodiment of the present application aims at the situation where two or more active components are started during the cold start process of the application and the first active component is invisible. While maintaining the migration logic of the startup window, the properties of the second task stack are changed, and its invisibility is changed in advance so that the second active component is started in the visible second task stack. In this way, the startup window can always be displayed in the second task stack, and the problem of splash screen caused by the invisible task stack causing the startup window to be invisible will not occur. This can make the cold start process of the application respond quickly and avoid splash screen.
[0227] FIG10 is a schematic diagram of an application startup device provided in an embodiment of the present application.
[0228] As shown in FIG10 , in some embodiments, the electronic device can implement corresponding functions through the software device shown in FIG10 . The application launching device 200 may include:
[0229] The first display module 201 is used to display a first startup window attached to the upper layer of the first Activity within a first life cycle corresponding to the first Activity based on a user's cold start operation on the first application. When the first application starts at least one invisible first Activity, the first startup window is displayed, wherein the first Activity is located in a visible first task stack, and the first task stack is associated with the first Activity.
[0230] The first migration module 202 is used to migrate the first startup window to the second Activity after the first life cycle ends and when the first application starts a visible second Activity, and in 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.
[0231] The first cancellation module 203 is used 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 first task stack, wherein 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.
[0232] The second display module 204 is used 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 the second startup window is displayed.
[0233] The application startup device 200 shown in the embodiment of the present application changes the migration logic of the startup window to address the situation where two or more active components are started during the cold start process of the application and the first active component is invisible, so that the startup window is migrated within the same task stack instead of migrating across task stacks. In this way, the cold start process of the application can respond quickly and the screen flashing problem can be avoided.
[0234] FIG11 is a schematic diagram of an application startup device provided in another embodiment of the present application.
[0235] As shown in FIG11 , in some other embodiments, the electronic device may implement corresponding functions through the software device shown in FIG11 , and the application launching device 300 may include:
[0236] The third display module 301 is used to display a third startup window attached to the upper layer of the first Activity within the first life cycle corresponding to the first Activity based on the user's cold start operation on the first application. When the first application starts at least one invisible first Activity, the third startup window is displayed, wherein the first Activity is located in the visible first task stack, and the first task stack is associated with the first Activity.
[0237] The second migration module 302 is used to migrate the third startup window to the second Activity after the first life cycle ends and, when the first application starts a visible second Activity, preset the layer attribute of the second task stack associated with the second Activity to visible during the migration of the third startup window.
[0238] The fourth display module 303 is used 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.
[0239] The application startup device 300 shown in the embodiment of the present application aims at starting two or more active components during the cold start process of the application and the first active component is invisible. While maintaining the migration logic of the startup window, the properties of the second task stack are changed, and its invisibility is changed in advance so that the second activity is started in the visible second task stack. In this way, the startup window can always be displayed in the second task stack, and the problem of splash screen caused by the invisible task stack causing the startup window to be invisible will not occur. This can make the cold start process of the application respond quickly and avoid splash screen.
[0240] FIG12 is a schematic structural diagram of an application startup device provided in an embodiment of the present application.
[0241] As shown in Figure 12, in one embodiment, an electronic device can implement corresponding functions using the hardware device shown in Figure 12. The device may include: a touch screen 401, a memory 402, a processor 403, and a communication module 404. The aforementioned components may be connected via one or more communication buses 405. The aforementioned components may be connected via one or more communication buses 405. The touch screen 401 may include a display panel 4011 and a touch sensor 4012. The display panel 4011 is used to display images, and the touch sensor 4012 may transmit detected touch operations to the application processor 403 to determine the type of touch event and provide visual output related to the touch operation via the display panel 4011. The processor 403 may include one or more processing units, such as 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. The different processing units may be independent devices or integrated into 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 a volatile memory and / or a non-volatile memory. When the processor executes the computer instructions, the electronic device may perform various functions or steps of the above method embodiments.
[0242] When the software program and / or multiple groups of instructions in the memory 402 are executed by the processor 403, the electronic device implements 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, display a first startup window attached to the upper layer of the first activity, wherein the first activity is located in a 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, migrate the first startup window to the second activity, and in 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; when the second activity is located in the second task stack, cancel the migration of the first startup window, so that the first startup window retains the use of the first task stack, wherein 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 in the second activity and the second task stack, and the second startup window is displayed, destroy the first startup window and display the second startup window.
[0243] In 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, wherein the first Activity is located in a 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 in the process of migrating the third startup window, the layer properties of the second task stack associated with the second Activity are preset to 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.
[0244] The present application also provides an electronic device, comprising: 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 executes the application startup method in any implementation manner in the above embodiments.
[0245] An embodiment of the present application also provides a chip system, which includes at least one processor and at least one interface circuit. The processor and the interface circuit can be interconnected via lines. 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 instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which is not specifically limited in the embodiment of the present application.
[0246] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes the various functions or steps executed in the above-mentioned method embodiment.
[0247] The embodiment of the present application further provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the various functions or steps executed in the above method embodiment.
[0248] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0249] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0250] Units described as separate components may or may not be physically separate, and components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0251] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0252] 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 this understanding, the technical solution of the embodiment of the present application is essentially 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, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0253] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of this application in detail. It should be understood that the above are only specific implementation methods of this application and are not intended to limit the scope of protection of this application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of this application should be included in the scope of protection of this application.< / activity>
Claims
1. A method for starting an application, characterized in that: include: Based on a cold start operation of a first application by a user, when the first application starts at least one invisible first activity component, within a first life cycle corresponding to the first activity component, a first start window attached to an upper layer of the first activity component is displayed, wherein 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 launch window to the second activity component, and during the migration of the first launch window, determine whether the second activity component is located in an invisible second task stack, the second task stack being associated with the second activity component; In the case where the second active component is located in the second task stack, cancel the migration of the first startup window, so that the first startup window retains the use of the first task stack, wherein 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 display the second startup window, 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 includes: In the case that the second active 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 active 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, the method further includes: Determining whether the first application has enabled a startup window function; In a case where the first application enables the startup window function, the display content of the first startup window is acquired, and the first startup window is created according to the display content.
4. The application startup method according to claim 3, characterized in that: After determining whether the first application has enabled the start window function, the method further includes: In a case where the first application does not enable the startup window function, determining whether the first application can add the first startup window; In the case that the first application can add the first startup window, the display content of the first startup window is acquired, and the first startup window is created according to the display content.
5. The application startup method according to claim 4, characterized in that: After the first life cycle ends, when the first application starts a visible second activity component, the method further includes: A first layer corresponding to the second startup window is created based on the second activity component, and the first layer is processed to send the processed first layer to a surface compositor 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 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; The second startup window is sent to a display driver through the SurfaceFlinger.
7. The application startup method according to claim 6, characterized in that: The creating a 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: Calculate the size of the second layer and update the drawing state of the second layer; After calculating the size of the second layer and updating the drawing status of the second layer, the second layer is sent to the SurfaceFlinger.
8. The application startup method according to claim 1, characterized in that: After displaying the second startup window, the method further includes: When the preset conditions are met, the display of the second startup window is switched to the display of the application interface corresponding to the first application, wherein the preset conditions include: 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 the title bar and navigation bar in the application interface.
9. A method for starting an application, characterized in that: include: Based on a cold start operation of the first application by the user, when the first application starts at least one invisible first activity component, within a first life cycle corresponding to the first activity component, a third start window attached to an upper layer of the first activity component is displayed, wherein 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, the third launch window is migrated to the second activity component, and in the process of migrating the third launch window, the layer attribute of the second task stack associated with the second activity component 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.
10. The application startup method according to claim 9, characterized in that: Before displaying the third start window attached to the upper layer of the first activity component, the method further includes: Determining whether the first application has enabled a startup window function; In a case where the first application enables the startup window function, the display content of the third startup window is acquired, and the third startup window is created according to the display content.
11. The application startup method according to claim 10, characterized in that: After determining whether the first application has enabled the start window function, the method further includes: In a case where the first application does not enable the launch window function, determining whether the first application can add the third launch window; In the case that the first application can add the third startup window, the display content of the third startup window is acquired, and the third startup window is created according to the display content.
12. The application startup method according to claim 11, characterized in that: After displaying the third startup window based on the visible second task stack, the method further includes: When the preset conditions are met, the display of the third startup window is switched to the display of the application interface corresponding to the first application, wherein the preset conditions include: 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 the title bar and navigation bar in the application interface.
13. An electronic device, characterized in that: include: 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 startup method as described in any one of claims 1-12.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the application startup method according to any one of claims 1 to 12.
15. A computer program product, characterized in that When the computer program product is run on an electronic device, the electronic device executes the application startup method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Managing a succession of deployments of an application programming interface (api) server configuration in the software lifecycle development
CN105431822A
Application program starting method and device, storage medium and terminal
CN108958830A
User interface display method and device of application based on sub-application program
CN115237483A
Application display method, electronic equipment and storage medium
CN116302291A