Small program starting method and related equipment
By preloading the empty process of the applet and synchronously executing the camera code scanning action and mini program initialization, the problem of long-term startup of the applet is solved and the user experience is improved.
Patent Information
- Application Number
- CN202311855140.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-12-28
AI Technical Summary
In the prior art, it takes a long time to start a mini program based on the scan function, which affects the user's waiting time and user experience.
By preloading the empty applet process, synchronously performing the camera code scanning action and mini program initialization, reducing the time to start the applet.
Shorten the startup time of the mini program and improve the user experience.
Smart Images

Figure CN120276781A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of terminals, and in particular, to a method for starting a mini-program and related devices. Background Art
[0002] An electronic device can provide various services. For example, a scanning service. The electronic device can use the scanning function to scan scannable codes, such as two-dimensional codes, barcodes, and mini-program codes.
[0003] In a possible implementation, the electronic device can conveniently start a mini-program based on scanning a scannable code. For example, in a food ordering scenario, the user can use the scanning function to enter the merchant's food ordering mini-program; in a cycling scenario, the user can use the scanning function to start the bike mini-program; in a food pickup scenario, the user can use the scanning function to enter the food pickup mini-program to pick up food, etc.
[0004] However, in a possible implementation, the time taken for the electronic device to start a mini-program based on the scanning function is relatively long, which prolongs the waiting time of the user and affects the user experience. Summary of the Invention
[0005] Embodiments of this application provide a method for starting a mini-program and related devices, which are applied to the technical field of terminals; in the scenario of starting a mini-program by scanning a code, by preloading an empty mini-program process, the time used to start the mini-program is shortened, thereby improving the user experience.
[0006] In a first aspect, an embodiment of this application proposes a method for starting a mini-program. The method includes: displaying a first interface of a first application, where the first interface includes a first button for pulling up a second application to perform code scanning; in response to an operation on the first button, pulling up an empty process of a first mini-program and controlling a camera to perform image acquisition; the second application is different from the first application; when the image captured by the camera is a scannable code of a first target mini-program, starting the first target mini-program by using the empty process of the first mini-program. In this way, by initializing the mini-program in advance when receiving a click on the scan button, the action of the electronic device starting the camera to scan the code is synchronized with the initialization of the mini-program, thereby reducing the time used to start the mini-program and improving the user experience.
[0007] In a possible implementation manner, the first application includes a desktop application launcher, and the first interface includes a desktop and / or a negative first screen. In this way, the electronic device can quickly start a mini-program in a code scanning scenario, reduce the waiting time of the user, and improve the user experience.
[0008] In a possible implementation, starting the first target applet by using the first applet empty process includes: loading the content of the first target applet into the first applet empty process; where the content of the first target applet includes the basic information of the target applet and the code package of the target applet. In this way, the effect of quickly starting the applet can be achieved by loading the content of the applet into the pre-loaded empty process.
[0009] In a possible implementation, before starting the first applet empty process, it further includes: determining whether the first button is a shortcut button; in the case where the first button is a shortcut button, obtaining the name of the shortcut; starting the first applet empty process includes: in the case where the name of the shortcut is a preset name, starting the first applet empty process. In this way, the electronic device can determine the code scanning scenario according to the determination condition, improving the accuracy of the applet startup method in the embodiments of the present application; in a non-code scanning scenario, the electronic device does not pre-start the applet empty process to avoid wasting memory.
[0010] In a possible implementation, after starting the first applet empty process, it further includes: keeping the first applet empty process alive within the keep-alive time threshold. In this way, by keeping the applet empty process alive, the death of the applet empty process can be reduced; thereby improving the utilization rate of the applet empty process and shortening the time for starting the applet.
[0011] In a possible implementation, keeping the first applet empty process alive includes: querying the registration status of the first applet empty process; the registration status is used to indicate whether to keep the process alive; in the case where the registration status of the first applet empty process is registered, querying the keep-alive time of the first applet empty process; in the case where the keep-alive time of the first applet empty process is less than or equal to the keep-alive time threshold, querying the system memory; in the case where the system memory is greater than or equal to the system memory threshold, not killing the first applet empty process. In this way, in a low-memory killing scenario, the electronic device can avoid the applet empty process being killed due to low memory, improving the survival rate of the applet empty process, thereby improving the utilization rate of the applet empty process, shortening the time for starting the applet, reducing the user waiting time, and improving the user experience.
[0012] In a possible implementation, before keeping the first small program empty process alive, it includes: registering and keeping the first small program empty process alive; the registration status of the small program empty process is registered; adding the first small program empty process to the keep-alive queue; setting the priority of the first small program empty process; the priority of the first small program empty process is higher than that of the empty process. In this way, in the low-memory killing scenario, the electronic device can avoid the small program empty process being killed due to low memory, improve the survival rate of the small program empty process, thereby improving the utilization rate of the small program empty process, shortening the time for starting the small program, reducing the user waiting time, and enhancing the user experience.
[0013] In a possible implementation, it further includes: when an operation on the first button is received in the first interface, pulling up the first small program empty process and controlling the camera to perform image acquisition; when the image captured by the camera is the scannable code of the second target small program, using the first small program empty process to start the second target small program; the second target small program is different from the first target small program. In this way, the electronic device can shorten the time for starting the small program by preloading the small program empty process.
[0014] In a possible implementation, it further includes: displaying the first interface of the first application, the first interface further includes a second button for pulling up the third application for scanning the code; the third application is different from the second application; when an operation on the second button is received, pulling up the second small program empty process and controlling the camera to perform image acquisition; the second small program empty process is different from the first small program empty process; when the image captured by the camera is the scannable code of the third target small program, using the second small program empty process to start the third target small program, and the third target small program is different from the second target small program. In this way, the embodiments of the present application are not limited to the scanning code scenario of a single application program, enrich the application scenarios of the small program startup method in the embodiments of the present application, and in multiple scanning code scenarios, the time for starting the small program can be shortened, and the user experience can be improved.
[0015] In a second aspect, embodiments of the present application provide an electronic device, which may also be referred to as a terminal device, a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The terminal device may be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, and so on.
[0016] The electronic device includes: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the method as in the first aspect.
[0017] In a third aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the method as in the first aspect is implemented.
[0018] In a fourth aspect, embodiments of the present application provide a computer program product including a computer program. When the computer program is run, a computer is enabled to execute the method as in the first aspect.
[0019] Embodiments of the present application provide a chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line. The at least one processor is configured to run a computer program or instruction to execute the method as in the first aspect.
[0020] It should be understood that the second to fifth aspects of the present application correspond to the technical solutions of the first aspect of the present application. The beneficial effects obtained by each aspect and the corresponding feasible implementation manners are similar and will not be elaborated herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 FIG. is a schematic diagram of an interface for scanning a code to start a small program provided by an embodiment of the present application;
[0022] Figure 2 It is a schematic flow chart of starting a mini program by scanning a code in a possible implementation;
[0023] Figure 3 It is a schematic structural diagram of the electronic device 100 provided in an embodiment of the present application;
[0024] Figure 4 It is a software structure block diagram of the electronic device 100 provided in an embodiment of the present application;
[0025] Figure 5 It is a schematic flow chart of a method for starting a mini program provided in an embodiment of the present application;
[0026] Figure 6 It is a schematic flow chart of starting a mini program by scanning a code in an embodiment of the present application;
[0027] Figure 7 It is a schematic flow chart of the detection process provided in an embodiment of the present application;
[0028] Figure 8 It is a schematic flow chart of preloading an empty process of a mini program provided in an embodiment of the present application;
[0029] Figure 9 It is a schematic flow chart of starting a mini program provided in an embodiment of the present application;
[0030] Figure 10 It is a schematic flow chart of keeping an empty process of a mini program alive provided in an embodiment of the present application;
[0031] Figure 11 It is a schematic flow chart of a method for starting a mini program provided in an embodiment of the present application;
[0032] Figure 12 It is a schematic structural diagram of a device for starting a mini program provided in an embodiment of the present application. Detailed implementation manners
[0033] To facilitate a clear description of the technical solutions in the embodiments of the present application, in the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.
[0034] In the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, or B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the front and back associated objects. "At least one (item)" or its similar expression refers to any combination of these items, including any combination of single item (item) or plural items (items). For example, at least one (item) of a, b, or c can represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c can be single or multiple.
[0035] It should be noted that "when...", in the embodiments of the present application, can be at the instant when a certain situation occurs or within a period of time after a certain situation occurs. The embodiments of the present application do not make specific limitations on this. In addition, the display interface provided in the embodiments of the present application is only an example, and the display interface can also include more or less content.
[0036] First, in combination with Figure 1 the process of starting a mini program based on scanning by an electronic device will be described. As Figure 1 shown:
[0037] The electronic device can display a desktop. For example, the desktop can be the interface shown in a of Figure 1 ; among them, Figure 1 the interface shown in a of Figure 1 can be the first interface among multiple desktop interfaces. When the electronic device receives a right - swipe operation, the electronic device can display the negative first screen; the negative first screen can be the interface shown in b of
[0038] In Figure 1 the interface shown in b of Figure 1 , the electronic device can display recommended services, shortcuts of commonly used applications, and resident services, etc. For example, the shortcuts of commonly used applications include a shortcut for scanning. The scanning function can be used to scan scannable codes such as QR codes, barcodes, and mini program codes; this interface displays a scan button 101. When the electronic device receives a trigger operation for the scan button 101, the electronic device can display the interface shown in c of
[0039] In Figure 1 the interface shown in c of Figure 1 the electronic device can display the image captured by the camera. For example, the electronic device displays a scannable code 102, and the scannable code 102 can be a mini program code. When the electronic device recognizes the scannable code 102, it can jump to the interface corresponding to the scannable code 102. For example, if the scannable code 102 is a mini program code for sending express delivery, Figure 1The interface shown as d in can be the interface of a small program for sending express delivery.
[0040] In another way, the electronic device can use the shortcut on the desktop to enter the scan interface. For example, the electronic device can display the desktop, and the desktop can be, for example, Figure 1 the interface shown as e in . Figure 1 The scan shortcut, such as the scan button 103, is displayed in the interface shown as e in . When the electronic device receives a trigger operation for the scan button 103, the electronic device can display the interface as shown in Figure 1 c in . After the electronic device recognizes the scannable code 102, it can display the interface as shown in Figure 1 d in .
[0041] In a possible implementation, the electronic device can use, for example, the above two methods to conveniently enter the small program through the scan function. However, during this process, there may be a problem scenario where the electronic device loads Figure 1 the interface shown as d in too slowly, prolonging the user's waiting time and affecting the user's scanning experience.
[0042] Next, in combination with Figure 2 we will analyze the reasons for the long time taken to enter the small program by scanning the code in a possible implementation, as shown in Figure 2 :
[0043] In a possible implementation, the electronic device can start the small program in the application interface or use the scan function to enter the small program. Among them, the process of starting the small program can be as shown in Figure 2 :
[0044] In a possible implementation, the electronic device can also start the small program through applications (such as social applications, video applications, and payment applications, etc.).
[0045] Taking starting the small program by scanning the small program code as an example, the electronic device detects a trigger operation when the user clicks the scan button. In response to this operation, the electronic device starts the application and launches the camera service. After launching the camera service, the electronic device detects an operation of scanning the small program code. In response to the operation of scanning the small program code, it opens the startup interface of the small program.
[0046] After displaying the startup interface of the small program, it starts to initialize the small program process. After the initialization is completed, the electronic device opens the small program interface. After the electronic device displays the small program interface, it starts to load the content of the small program. After the loading is completed, the user can use the small program.
[0047] In a possible implementation, the time taken from when the user clicks the "Scan" button until the applet is fully launched exceeds 5 seconds, which is a relatively long time. The time taken to launch the applet by scanning the applet code can be roughly divided into the following stages. The time taken from clicking the "Scan" button until the launch interface is displayed may be related to the user's operation of aligning the camera with the object to be scanned, and generally, this duration will exceed 0.5 seconds. The time taken from when the applet initializes until it is fully initialized is about 2 seconds; the time taken from when the applet interface is displayed until the applet is fully launched is about 2 seconds. It can be seen that the process from when the user performs the triggering operation until the electronic device fully launches the applet takes a relatively long time, and the user needs to wait for a long time, which affects the user experience.
[0048] In view of this, an embodiment of the present application provides a method for launching an applet. When launching the "Scan" application, a blank process of the applet is pulled up and the applet is initialized. Subsequently, when the applet code is scanned, the content of the applet is loaded into the pre-loaded blank process of the applet, and the applet launch is completed. In this way, the step of initializing the applet can be advanced to after launching the "Scan" application, thereby reducing the time taken to initialize the applet, further reducing the overall time taken to launch the applet, reducing the user's waiting time, and enhancing the user's usage experience.
[0049] In order to better understand the embodiments of the present application, the structure of the electronic device in the embodiments of the present application will be introduced below:
[0050] Figure 3 The schematic structural diagram of the electronic device 100 is shown. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, a subscriber identification module (SIM) card interface 195, and an embedded secure element (eSE) 196, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0051] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those illustrated, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0052] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0053] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be called from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0054] In the embodiments of the present application, the processor 110 can be used to process the information processing-related processes in the small program startup method of the embodiments of the present application.
[0055] The electronic device 100 realizes the display function through the GPU, the display screen 194, and the application processor, etc.
[0056] The display screen 194 is used to display images, videos, etc. In the embodiments of the present application, the display screen 194 can be used to display an interface related to the code scanning process as Figure 1 shown, for example, the display screen 194 can display a desktop, a negative first screen, a code scanning interface, and a small program running interface, etc.
[0057] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.
[0058] The camera 193 is used to capture static images or videos. In the embodiments of this application, the electronic device 100 can collect scannable codes through the camera to implement the code scanning process.
[0059] The internal memory 121 can be used to store computer-executable program codes, and the executable program codes include instructions. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, the image playback function, etc.). The data storage area can store the data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include high-speed random access memory, and can also include 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 the instructions stored in the internal memory 121, and / or the instructions stored in the memory provided in the processor.
[0060] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture, etc. In the embodiments of this application, taking the Android system with a layered architecture as an example, the software structure of the electronic device 100 is illustrated by way of example.
[0061] Figure 4 It is the software structure block diagram of the electronic device 100 in the embodiments of this application.
[0062] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system can include: the application layer (applications), the application framework layer (application framework), the system layer, and the kernel layer (kernel), where the kernel layer may become the driver layer.
[0063] The application layer can include a series of application program packages.
[0064] Such as Figure 4 shown, the application program packages can include the Scan application, the desktop application (launcher), the preloading module, and the target applet. In the embodiments of this application, the electronic device can also preload the applet empty process in advance. In addition, the application layer can also include application programs associated with the Scan application, such as social applications and payment applications, as well as application programs such as the camera application and the music application (not shown in Fig. 4).
[0065] Among them, the launcher is the desktop launcher of the electronic device. Herein, the desktop UI of the electronic device is collectively referred to as the launcher. The launcher can be used to display and manage other application programs in the electronic device. For example, when the electronic device receives a trigger operation on the icon of an application program on the desktop, the electronic device can start the application program based on the launcher.
[0066] The scan application can be an application used to scan scannable codes. For example, the scan application can have shortcuts that support scanning scannable codes related to social applications, payment applications, etc.
[0067] The target applet can be an applet entered based on scanning an applet code.
[0068] In the embodiments of the present application, the application layer may include a preloading module, and the preloading module can be used to pre-launch an empty process of the applet; for example, when receiving an operation to start the scan application, an empty process of the applet is launched.
[0069] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the application programs in the application layer. The application framework layer includes some predefined functions.
[0070] As Figure 4 shown, the application framework layer may include an activity manager.
[0071] The activity manager is responsible for managing transactions related to activities such as the start, status, and life cycle of the activities of the application. Among them, an activity is an application component that can provide an interface for the user to interact with the terminal device through this interface to complete a certain task.
[0072] In the embodiments of the present application, the activity manager can query the empty process of the applet based on the instruction of the preloading module, and when the empty process of the applet is not queried, launch the empty process of the applet.
[0073] The system layer may include functional modules. For example, in the embodiments of the present application, the system layer may include a keep-alive module.
[0074] The keep-alive module is used to keep the empty process of the applet alive and improve the survival rate of the empty process of the applet. For example, in the embodiments of the present application, the keep-alive module can add the empty process of the applet to the keep-alive queue.
[0075] The kernel layer is the layer between the hardware and the software. The kernel layer is used to drive the hardware to make the hardware work. The kernel layer may include memory management.
[0076] Memory management is used to manage the operation data stored in the CPU. For example, memory management can allocate a reasonable memory size for a process to ensure that the process can run properly without running out of memory or each process occupying too much memory. When the system memory is insufficient, memory management can kill some processes that are currently occupying memory to reduce the memory load.
[0077] The following will combine Figure 4 to illustrate the mini-program startup method of the embodiments of the present application.
[0078] When receiving an operation of clicking the scan button, the launcher can obtain relevant information of the scan application. When the launcher determines that the clicked button is the button of the scan application, it can send an instruction for pulling up the empty process of the mini-program to the preloading module. The preloading module obtains the process name and the keep-alive time threshold of the empty process of the mini-program according to the instruction. The preloading module instructs the activity manager to query whether the empty process of the mini-program exists, and pulls up the empty process of the mini-program when it does not exist. After pulling up the empty process of the mini-program, the keep-alive module keeps the empty process of the mini-program alive. Within the keep-alive time threshold, memory management does not kill the empty process of the mini-program; after exceeding the keep-alive time threshold, memory management kills the empty process of the mini-program. This process can be as Figure 4 shown by the solid line part in
[0079] In addition, when the launcher determines that the clicked button is the button of the scan application, the launcher can instruct the activity manager to perform a scan operation; the activity manager pulls up the camera; after the camera captures a scannable code, the electronic device can start the target mini-program by using the empty process of the mini-program; this process can be as Figure 4 shown by the dashed line part in
[0080] The following will first combine Figure 5 to illustrate the overall solution of the mini-program startup method in the embodiments of the present application, as Figure 5 shown:
[0081] The electronic device may include a desktop application, a preloading module, and an activity manager.
[0082] Exemplarily, S501. The desktop application receives a trigger operation for the scan button.
[0083] The desktop application may include a scan application. For example, the negative first screen may display one or more scan buttons, such as the interface shown as b in Figure 1 ; or for another example, the desktop may display one or more scan buttons, such as the interface shown as e in Figure 1 . The trigger operation for the scan button may be, for example: a click operation on the scan button 101 in the interface shown as b in Figure 1 ; and / or a click operation on Figure 1The click operation on the Scan button 103 in the interface shown in e.
[0084] It should be noted that in the embodiments of the present application, the desktop application may include multiple Scan applications. For example, the Scan of any social application, the Scan of any payment application, etc.; different Scan applications may support scanning the mini-program code under the application corresponding to the Scan function; the application corresponding to the Scan function can be understood as: the electronic device can enter the mini-program through this application; it can also enter the mini-program in the form of scanning the mini-program code through the Scan function under this application platform. The embodiments of the present application do not limit the number of Scan buttons and their corresponding applications.
[0085] S502. In response to the trigger operation, the desktop application issues an instruction for pulling up the empty process of the mini-program.
[0086] The empty process of the mini-program can be understood as: an empty process that can support the operation of the mini-program; for example, the empty process of the mini-program may include the running environment of the mini-program. Specifically, for example, the running environment may include the mini-program process and the basic application modules in the Native layer; part of the UI and system components in the view layer, part of the web view (Webview) and the mini-program basic library; and the JavaScript (JS) engine and the mini-program basic library in the logic layer, etc.
[0087] It can be understood that the electronic device can run the mini-program based on the rendering layer and the logic layer. The rendering layer is mainly responsible for using WebView to display and render the mini-program interface, and the logic layer is mainly responsible for the logic processing and data interaction of the mini-program, and uses the JsCore thread to run the JS script. The rendering layer and the logic layer are independent of each other and can communicate with each other.
[0088] In the embodiments of the present application, the components required for running the mini-program can be classified according to the applicable scope of the components in the rendering layer and the logic layer. For example, the first type of components may include mini-program components applicable to multiple mini-programs, and the second type of components may include mini-program components applicable to a single mini-program. The first type of components can be understood as the parts that can be reused by multiple mini-programs; the second type of components can be understood as the parts related to a specific mini-program, and other mini-programs may not be able to reuse these components; the specific mini-program can be the target mini-program. The first type of components can be, for example, the running environment of the mini-program mentioned above, as well as page routing and navigation, animation effects and transitions, life cycle functions (such as onLaunch, onShow, onHide, etc.), information for user authorization and login, information for indicating device functions and interface calls, etc. The second type of components can be, for example, the components used when loading the target mini-program, such as the basic information and code package of the target mini-program.
[0089] After receiving a trigger operation for the scan button, the desktop application can send an instruction to the preloading module to launch the empty process of the applet.
[0090] S503. The preloading module obtains the process name and the keep-alive time threshold of the empty process of the applet according to the instruction.
[0091] The process name of the empty process of the applet is related to the application program, and the process names of the empty processes of the applets under different application program platforms are different. For example, the process names of the empty processes of the applets of the WeChat application can be appbrand0 and appbrand1, and the process name of the empty process of the applet of the Alipay application can be lite1, etc.
[0092] The preloading module can determine the application program corresponding to the scan button that receives the click operation, and obtain the process name of the empty process of the applet corresponding to the application program. In the embodiments of the present application, the empty process of the applet preloaded by the electronic device needs to correspond to the application program, otherwise there may be a problem scenario where the applet under the application program cannot be loaded in the empty process of the applet.
[0093] Optionally, in the embodiments of the present application, the empty process of the applet can be kept alive by the keep-alive time threshold. For example, when the keep-alive time of the empty process of the applet does not reach the keep-alive time threshold, the electronic device can continue to keep the empty process of the applet alive until the keep-alive time reaches the keep-alive time threshold, and the electronic device cancels the keep-alive of the empty process of the applet. It can be understood that the electronic device will regularly kill the empty process to reduce the waste of memory resources caused by the unrun tasks in the empty process. The embodiments of the present application can set the keep-alive time of the empty process of the applet to prevent the electronic device from killing the empty process of the applet during the startup of the applet.
[0094] S504. The activity manager queries whether there is an empty process of the applet according to the process name.
[0095] The preloading module passes the process name of the empty process of the applet to the activity manager. The activity manager can query in the currently running processes according to the process name and confirm whether there is a surviving empty process of the applet currently.
[0096] Taking the empty process of the applet as appbrand0 as an example, the activity manager searches for appbrand0 among the multiple processes running in the current memory. If appbrand0 exists, step S506 is executed; if appbrand0 does not exist, step S505 is executed first, and then step S506 is executed.
[0097] S505. In the case where the empty process of the applet does not exist, the activity manager launches the empty process of the applet.
[0098] In the case where the empty mini-program process does not exist, the electronic device can create a new empty process and inject the first type of components into the new empty process. For example: initialize the mini-program process and WeChat basic modules at the Native layer; pre-create some UI and system components in the view layer, initialize some web views (Webview), and inject the mini-program basic library; and initialize and pre-create the JavaScript (JS) engine in the logic layer and inject the mini-program basic library, etc.
[0099] Taking the mini-program empty process appbrand0 as an example, before pulling up the mini-program empty process, the process running in the memory does not include appbrand0; after pulling up the mini-program empty process, the process running in the memory includes appbrand0.
[0100] In some embodiments, the process of pulling up the mini-program empty process can be the stage of binding the application (bindapplication).
[0101] S506. The preloading module keeps the mini-program empty process alive according to the keep-alive time threshold.
[0102] After pulling up the mini-program empty process, the mini-program empty process may be killed by the memory management due to low memory. To avoid the situation that the just-pulled-up mini-program empty process is killed without being used, the embodiment of the present application sets a keep-alive time threshold for the mini-program empty process. Within the keep-alive time threshold, the memory management will not kill the mini-program empty process.
[0103] Among them, the keep-alive time threshold of the mini-program empty process can be, for example, 10s. It can be understood that in the actual scenario, after the user sees the scannable code, they click the scan button; after the electronic device wakes up the camera service, the camera is aimed at the scannable code to implement the scanning process. After receiving the operation on the scan button, it can be considered that the user has the intention to use the mini-program code for scanning, and the electronic device preloads the mini-program empty process. Generally, the user will complete the scanning process within a short time, so a shorter keep-alive time threshold can be set, for example, 10s.
[0104] S507. Within the keep-alive time of the mini-program empty process, the desktop application recognizes the scannable code.
[0105] This scenario can be, for example, Figure 1 the interface shown in c in. The electronic device wakes up the camera service and uses the camera to collect the scannable code. The desktop application recognizes the scannable code to confirm whether the scannable code is a mini-program code. When the scannable code is a mini-program code, step S508 can be executed.
[0106] S508. The preloading module loads the mini-program content corresponding to the scannable code in the mini-program empty process.
[0107] After the electronic device recognizes a scannable code, it can control the jump to the interface corresponding to the scannable code, such as Figure 1 the interface shown in d in Figure 1 . In some embodiments, the preloading module can inject a second type of component into the empty process of the applet, and the second type of component includes a component for rendering and displaying, for example,
[0108] It can be understood that in the embodiments of the present application, the order of starting the applet is readjusted to achieve the effect of reducing the time taken to start the applet by scanning the code. The following combines Figure 6 to illustrate the process of starting the applet in the embodiments of the present application, as Figure 6 shown:
[0109] When receiving a trigger operation for the scan button, the electronic device starts an application program, and the application program can be an application program corresponding to the scan button; after the electronic device starts the application program, the electronic device can also call the camera service so that the electronic device can collect an image of the scannable code based on the camera; the electronic device finishes starting the application program.
[0110] After that, the electronic device can scan the scannable code based on the camera, such as Figure 1 the interface shown in d in
[0111] In addition, when receiving a trigger operation for the scan button, the electronic device can also preload the empty process of the applet to realize the initialization of the applet. Subsequently, when the electronic device displays the startup interface of the applet based on the scannable code, the electronic device starts to display the applet interface (appbrandUI) and loads content in the empty process of the applet until the applet startup process is completed.
[0112] In the first possible implementation, the time interval from clicking the scan button to scanning the scannable code is relatively long. For example, the time interval is greater than 2s. The process of the electronic device starting the applet can be as shown in Figure 6 Figure a in
[0113] Compared with Figure 2The small program startup process of possible implementations. In the embodiments of the present application, the electronic device advances the process of initializing the small program, so that the electronic device synchronously executes the steps from starting the application to displaying the startup interface and the step of initializing the small program. The time taken to initialize the small program completely after the startup interface is displayed is saved, thereby reducing the startup time of the small program.
[0114] In the second possible implementation, the time interval from clicking the scan button to scanning a scannable code is short. For example, the time interval is less than 2 s. The process of the electronic device starting the small program can be as Figure 6 shown in Figure b of [reference]. After receiving the click on the scan button, the electronic device starts initializing the small program. Before the initialization of the small program is completed, the electronic device scans a scannable code and executes the process of starting the small program and displaying the startup interface. After the startup interface is displayed, the electronic device can continue to initialize the small program until the initialization of the small program is completed and start to display the small program interface. After the specific content of the small program is loaded in the empty process of the small program, the startup of the small program is completed.
[0115] Compared with Figure 2 the small program startup process of possible implementations. In the embodiments of the present application, the electronic device advances the process of initializing the small program, so that the electronic device synchronously executes the steps from starting the application to displaying the startup interface and the step of initializing the small program. The time for partially initializing the small program after the startup interface is displayed is saved, thereby reducing the startup time of the small program.
[0116] The above embodiments illustrate the process of starting a small program in the embodiments of the present application. The process of starting a small program can be divided into four processes. For example, the detection process before preloading the empty process of the small program; the process of preloading the empty process of the small program; the process of starting the small program, and the process of keeping the empty process of the small program alive after preloading the small program.
[0117] Next, the detection process before preloading the empty process of the small program will be described first in combination with Figure 7 [reference].
[0118] Exemplarily, as Figure 7 shown:
[0119] S701. When receiving a click operation, the launcher obtains the button corresponding to the click operation.
[0120] After the user performs a click operation on the screen, the launcher can obtain the click event, and the launcher can determine the clicked button based on the click operation. For example, the electronic device can add a tag to a view object in the interface through the setTag() function. After the view object is clicked, the electronic device can read the tag of the view object through the getTag() function to determine the clicked view object, and the view object can be a button.
[0121] S702. The launcher determines whether the button is a shortcut button of an application.
[0122] It can be understood that the scan application displayed on the desktop or the negative first screen can be a shortcut for the scan function in the application, and the scan button can be a shortcut button for the scan function in the application. Before determining whether the clicked button is the scan button, the click operations for applications such as the photo album and music can be filtered out by determining whether the button is a shortcut button.
[0123] Specifically, the launcher can obtain the tag through the getTag() function to determine whether the clicked button is a shortcut button. For example, the tag of the shortcut button is ShortcutInfo. After the launcher obtains ShortcutInfo, it can determine that the clicked button is a shortcut button, and the electronic device can execute step S703; otherwise, the detection process ends.
[0124] S703. When the button is a shortcut button of an application, the launcher obtains the intent of the shortcut button.
[0125] The intent of the shortcut button can be used to indicate the related operations that the electronic device can perform when clicking the button of the shortcut. For example, when the clicked button is a shortcut button, the electronic device can obtain the intent of the shortcut button and allocate corresponding components according to the intent to respond to the intent.
[0126] S704. The launcher obtains the position of the button on the screen.
[0127] The launcher can obtain the position of the button on the screen based on the intent and obtain the related data of the button according to the position. For example, the name of the button.
[0128] S705. The launcher obtains the data of the button, and the data of the button can include the name of the button.
[0129] Launcher can obtain the string corresponding to the button through the getResources() function. The string may include the name of the shortcut corresponding to the button. For example, the data of the Scan button can be getString(R.string.description_target_saoyisao), and the name of the button can be "saoyisao".
[0130] S706: The launcher determines whether the button is a scan button.
[0131] S707: When the button is a scan button, the launcher sends an instruction to the preloading module to start an empty process of the mini-program.
[0132] The launcher obtains the button tartet as "saoyisao", and determines that the button clicked is a scan button. At this time, the electronic device can detect the usage scenario of the mini-program startup method in the embodiment of the present application, and start executing the mini-program startup method provided in the embodiment of the present application.
[0133] In some embodiments, the launcher may send an instruction for launching an empty applet process to the preloading module via an asynchronous communication interface. For example, the asynchronous communication interface may be an IAwareSdk.asyncReportData interface.
[0134] S708: The activity manager starts the scan function.
[0135] It is understandable that upon receiving a trigger operation for the Scan button, the electronic device can launch a camera service to collect scannable codes; in addition, the electronic device can also instruct the preloading module to perform a preloading process for the empty process of the mini program. Therefore, after step S707, the electronic device can respond to the trigger operation for the Scan button according to the native process and launch the camera service.
[0136] For example, after the activity manager receives the instruction for starting the scan function, it starts the scan function by calling the start activity by click icon function.
[0137] In the embodiment of the present application, step S707 may be before step S708, or after step S708. For example, the electronic device may execute step S707 within a period of time after detecting that the clicked button is a scan button; step S708 of the native process may occur before step S707; wherein, this period of time may be less than the time taken to initialize the mini program, and the effect of shortening the time taken to start the mini program can still be achieved.
[0138] S709. The activity manager starts the camera.
[0139] Starting the camera can be understood as the activity manager pulling up the camera service, and the electronic device displays the interface shown as c in Figure 1 .
[0140] In this way, based on the scenario detection process, when the electronic device detects the scan button, it can start the preloading process of the applet; when the scan button is not detected, it does not start the preloading process of the applet; this reduces the problem scenario of memory occupation after accidentally starting the preloading process of the applet, and improves the accuracy of the applet startup method in the embodiments of this application.
[0141] Next, the process of preloading the empty process of the applet will be described in conjunction with Figure 8 .
[0142] After step S707, it further includes:
[0143] S801. The preloading module parses the instruction for pulling up the empty process of the applet and obtains the information of the empty process of the applet.
[0144] The instruction for pulling up the empty process of the applet may carry the information of the empty process of the applet. The information of the empty process of the applet may include the process ID (pid) of the empty process of the applet, the process name of the empty process of the applet and / or the package name of the application, and the keep-alive time threshold of the empty process of the applet.
[0145] S802. The preloading module instructs the activity manager to query whether there is an empty process of the applet in the current process.
[0146] The process list or process queue of the electronic device may include multiple processes running on the current electronic device, and the activity manager can query the process list or process queue from memory management.
[0147] The electronic device can query whether there is a surviving empty process of the applet in the electronic device according to the information of the empty process of the applet.
[0148] When the information of the empty process of the applet is not included in the process list or process queue, the activity manager can try to pull up the empty process of the applet, for example, execute steps S803 - S805; when the information of the empty process of the applet is included in the process list or process queue, the activity manager can notify the keep-alive module to keep the empty process of the applet alive, for example, execute steps S901 - S904.
[0149] S803. In the case where there is no empty process of the applet in the current process, the activity manager creates an empty process of the applet.
[0150] When there is no small program empty process running in the electronic device, the activity manager may instruct the zygote process to fork a new small program empty process.
[0151] S804. The activity manager loads the application context information of the small program empty process in the page framework file.
[0152] The application context information of the small program empty process may include information of the first type of components. In the page framework file after loading the application context information of the small program empty process, the information of the first type of components required for the initialization of the small program empty process can be configured.
[0153] S805. The activity manager initializes the small program empty process according to the page framework file.
[0154] The initialization process can be, for example, as described in step S505, which will not be elaborated here.
[0155] When a trigger button for the scan button is received, the electronic device can obtain the intention of the user to perform a scan; the electronic device can prepare the small program empty process in advance. When a small program code is scanned and the target small program is started, the small program empty process can be used to quickly launch the target small program.
[0156] In the embodiment of the present application, after determining that the clicked button is the scan button, the electronic device pulls up or queries the small program empty process, so that there can be one or more small program empty processes waiting to be used before the target small program code is scanned. In this way, the process of initializing the small program can be pre-executed, reducing the startup time of the small program.
[0157] The following combines Figure 9 to illustrate the process of starting a small program.
[0158] After step S805, it further includes:
[0159] S901. The camera identification scans the scannable code.
[0160] The scannable code can be the small program code of the target small program. The camera identification of the scannable code can be, for example, Figure 1 the interface shown in c.
[0161] S902. The activity manager obtains a request for starting the target small program.
[0162] The target small program can be the small program corresponding to the scannable code. The activity manager can obtain the information of the target small program to be started according to the small program code.
[0163] S903. The activity manager loads the content of the target small program in the small program empty process.
[0164] For example, the activity manager loads the application context information of the target mini-program and updates the page address of the page frame file to the page address of the target mini-program. The application context information of the target mini-program may include information about the second type of components.
[0165] S904. Start the target mini-program.
[0166] This step can be, for example Figure 1 the interface shown in d. After the electronic device starts the target mini-program, the functions of the target mini-program can be used.
[0167] In this way, after the electronic device scans the mini-program code, the electronic device can use the mini-program empty process to start the target mini-program.
[0168] Next, the process of keeping the mini-program empty process alive will be described in conjunction with Figure 10 this.
[0169] It can be understood that after the mini-program empty process is launched and before the target mini-program is loaded based on the mini-program empty process, during this period, the electronic device needs to ensure that the mini-program empty process is in a live state. Therefore, between steps S805 - S904, it is necessary to keep the mini-program empty process alive. As Figure 10 shown:
[0170] S1001. The preloading module registers the mini-program empty process with the keep-alive module.
[0171] The preloading module can instruct the keep-alive module to keep the mini-program empty process alive; the keep-alive module can register the keep-alive for the mini-program empty process. Before registration, the registration status of the mini-program empty process can be unregistered; after registration, the registration status of the mini-program empty process can be updated to registered.
[0172] S1002. The keep-alive module adds the mini-program empty process to the keep-alive queue.
[0173] After registration, the keep-alive module can add the mini-program empty process to the keep-alive queue. In some embodiments, the keep-alive module can add information such as the process ID of the mini-program empty process, the process name of the mini-program empty process, and / or the package name of the application to the keep-alive queue.
[0174] S1003. The keep-alive mode instructs the activity manager to set the process priority for the mini-program empty process.
[0175] The keep-alive module can reduce the killing of the mini-program empty process by the memory management by increasing the process priority of the mini-program empty process.
[0176] When the memory management kills processes, it can kill processes according to the process priority. Among them, the memory management will give priority to clearing processes with low priority, such as empty processes.
[0177] In the embodiments of the present application, the empty process of the applet before keep-alive is lower than that of the applet after keep-alive. Specifically, the activity manager can set an adj threshold for the empty process of the applet. Among them, the adj threshold is negatively correlated with the process priority. The smaller the adj threshold value, the higher the priority of the process. By setting a lower adj threshold for the empty process of the applet, the priority of the empty process of the applet can be improved to prevent the empty process of the applet from being killed. For example, the adj threshold of the empty process is generally 17, and the adj threshold of the empty process of the applet can be 12. The embodiments of the present application do not limit the specific value of the priority of the empty process of the applet.
[0178] After step S1003, it further includes:
[0179] S1004. When the memory management kills low-memory processes, the memory management can query the registration status of the empty process of the applet from the keep-alive module.
[0180] S1005. When the registration status of the empty process of the applet is registered, the memory management queries from the keep-alive module whether the keep-alive time is greater than the keep-alive time threshold.
[0181] It can be understood that when the keep-alive module does not register the empty process of the applet, the keep-alive module will not perform keep-alive on the empty process of the applet. Therefore, after the keep-alive module registers the empty process of the applet, the memory management will execute the subsequent query steps; otherwise, the memory management executes step 1008 to kill the empty process of the applet.
[0182] S1006. When the keep-alive time is less than or equal to the keep-alive time threshold, the memory management queries whether the system memory is less than the memory threshold.
[0183] Within the keep-alive time threshold, the keep-alive module can perform keep-alive processing on the empty process of the applet; when exceeding the keep-alive time threshold, the keep-alive module no longer performs keep-alive on the empty process of the applet; the memory management can execute step S1009 to kill the empty process of the applet.
[0184] S1007. When the system memory is greater than or equal to the memory threshold, the memory management does not kill the empty process of the applet.
[0185] The priority of the memory management to kill processes is related to the system memory. It can be understood that when the system memory occupancy is low, the system memory is relatively abundant, and keeping the empty process of the applet alive will not bring a high operating pressure to the system memory. When the system memory occupancy is high, keeping the empty process of the applet alive may bring an operating pressure to the system memory, and the memory management can kill the empty process of the applet.
[0186] In some embodiments, when the system memory is sufficient, the priority of the memory management anti-virus process is relatively low; when the system memory is insufficient, the priority of the memory management anti-virus process is relatively high. In the embodiments of the present application, by setting an appropriate adj threshold, small program empty processes are not killed when the system memory is sufficient, and small program empty processes are killed when the system memory is insufficient. In this way, when the system memory is less than the memory threshold, small program empty processes can be killed to preferentially ensure the normal operation of system-level processes, for example.
[0187] It should be noted that the embodiments of the present application illustrate the process of the memory management anti-virus process in the order of steps S1004 - S1006. In actual applications, the memory management can also first determine the system memory, and can also first determine the keep-alive time. The embodiments of the present application do not limit the sequence of the determination process.
[0188] Or, after step S1004, it further includes:
[0189] S1008. When the registration status of the small program empty process is unregistered, the memory management kills the small program empty process.
[0190] Or, after step S1005, it further includes:
[0191] S1009. When the keep-alive time is greater than the keep-alive time threshold, the memory management kills the small program empty process.
[0192] Or, after step S1006, it further includes:
[0193] S1010. When the system memory is less than the memory threshold, the memory management kills the small program empty process.
[0194] Steps S1008 - S1010 can refer to the relevant descriptions in steps S1005 - S1007, and will not be elaborated here.
[0195] After the user clicks to scan, the electronic device can keep the small program empty process alive so that the small program empty process can survive until the target small program is loaded; in this way, after scanning the small program code, the electronic device can use the small program empty process to start the target small program, thereby achieving the effect of quickly starting the target small program.
[0196] Based on the above embodiments, the embodiments of the present application provide a small program start method. Exemplarily, Figure 11 It is a schematic flowchart of a small program start method provided by the embodiments of the present application.
[0197] As Figure 11 shown, the small program start method may include the following steps:
[0198] S1101. Display the first interface of the first application. The first interface includes a first button, and the first button is used to launch the second application for code scanning.
[0199] The first application can be, for example, the launcher, and the first interface can be the desktop and / or the negative first screen. For example, Figure 1 the interface shown in e in Figure 1 and the interface shown in b in Figure 1 In the interface shown in b in Figure 1 the first button can correspond to the scan button 101; Figure 1 In the interface shown in e in the first button can correspond to the scan button 103. The scan button 101 or the scan button 103 can launch the second application for code scanning. For example, the second application is the WeChat application, and the first button can support scanning the mini-program code of the WeChat application. The second application can also be other applications, and the first button can also support scanning the mini-program codes of other applications.
[0200] It should be noted that in the embodiments of the present application, only taking the first application as a desktop application as an example to illustrate the process of starting a mini-program by code scanning. In the embodiments of the present application, the first application can also be other applications, and the embodiments of the present application do not limit this.
[0201] S1102. When receiving an operation on the first button, launch the first mini-program empty process and control the camera to perform image acquisition; the second application is different from the first application.
[0202] The first mini-program empty process can be one or more mini-program empty processes. The first mini-program empty process can be an empty process bound to the second application (bindapplication). For example, when the second application is the WeChat application, the first mini-program empty process is appbrand0 and / or appbrand1. The electronic device can launch two mini-program empty processes at the same time, or can launch one mini-program empty process. The embodiments of the present application do not limit this. The camera can be used to collect scannable codes.
[0203] The process of the electronic device launching the mini-program empty process can refer to the relevant descriptions in steps S801 - S805, which will not be elaborated here.
[0204] It can be understood that when receiving an operation on the first button, launching the first mini-program empty process can correspond to receiving an operation of clicking the scan button in Figure 6 Figure a in Figure 6 and the electronic device starts mini-program initialization; or, it corresponds to receiving an operation of clicking the scan button in Figure b in
[0205] S1103. When the image captured by the camera is a scannable code of the first target mini-program, start the first target mini-program by using the first mini-program empty process.
[0206] Among them, step S1103 can refer to steps S901 - S904, and the embodiments of the present application will not elaborate on this again.
[0207] It can be understood that the first mini-program empty process is configured with common components for running mini-programs under the second application; the first target mini-program can be any mini-program under the second application. Therefore, the electronic device can start the mini-program by configuring the specific components of the target mini-program in the first mini-program empty process. This process can correspond to Figure 6 the process from displaying the mini-program interface to completing the startup.
[0208] It should be noted that the processes shown in steps S1101 to S1103 can correspond to Figure 6 the process in Figure 2 Compared with the process shown in
[0209] It can be seen that in the possible implementation, it is necessary to perform mini-program initialization after scanning the scannable code; while in the embodiments of the present application, the process of mini-program initialization can be advanced to be executed after clicking the scan button, and the overall time used to start the mini-program is less than the time used to start the mini-program in the possible implementation.
[0210] Optionally, the first application includes the desktop application launcher, and the first interface includes the desktop and / or the negative first screen.
[0211] In this way, the electronic device can quickly start the mini-program in the scanning code scenario, reduce the waiting time of the user, and improve the user experience.
[0212] Optionally, starting the first target mini-program by using the first mini-program empty process includes: loading the content of the first target mini-program into the first mini-program empty process; where the content of the first target mini-program includes the basic information of the target mini-program and the code package of the target mini-program.
[0213] This step can refer to the relevant descriptions in steps S901 - S904, and the embodiments of the present application will not elaborate on this again.
[0214] In this way, the effect of quickly starting the mini-program can be achieved by loading the content of the mini-program into the pre-loaded empty process.
[0215] Optionally, before launching the first small program empty process, the method further includes: determining whether the first button is a shortcut button; when the first button is a shortcut button, obtaining the name of the shortcut; launching the first small program empty process, including: when the name of the shortcut is a preset name, launching the first small program empty process.
[0216] This process can refer to the relevant descriptions in steps S701 - S707. Among them, the electronic device can filter out click operations on applications such as the photo album and music in the desktop based on the determination condition of whether it is a shortcut button in step S702; the electronic device can determine whether the shortcut is a scan code based on the determination condition of whether it is a scan code button in step S706.
[0217] Specifically, when the label of the first button obtained by the electronic device is ShortcutInfo, it is determined that the first button is a shortcut button; the electronic device obtains the string corresponding to the first button through the getResources() function, and the string includes the name of the shortcut. When the name of the shortcut is a preset name (for example, saoyisao), it is determined that the first button is a scan code button, and an attempt is made to launch the first small program empty process.
[0218] In this way, the electronic device can determine the scan code scenario according to the determination condition, improving the accuracy of the small program startup method in the embodiments of the present application; in non - scan code scenarios, the electronic device does not pre - launch the small program empty process, avoiding wasting memory.
[0219] Optionally, after launching the first small program empty process, the method further includes: keeping the first small program empty process alive within the keep - alive time threshold.
[0220] The keep - alive threshold can be 10s. After launching the small program empty process, it is necessary to ensure that the small program empty process remains alive before using the small program empty process to start the target small program. After the small program empty process is killed, the electronic device cannot use the small program empty process to quickly start the target small program.
[0221] In this way, by keeping the small program empty process alive, the death of the small program empty process can be reduced; thereby improving the utilization rate of the small program empty process and shortening the time required to start the small program.
[0222] Optionally, keeping the first small program empty process alive includes: querying the registration status of the first small program empty process; the registration status is used to indicate whether to keep the process alive; when the registration status of the first small program empty process is registered, querying the keep - alive time of the first small program empty process; when the keep - alive time of the first small program empty process is less than or equal to the keep - alive time threshold, querying the system memory; when the system memory is greater than or equal to the system memory threshold, not killing the first small program empty process.
[0223] This process can refer to the relevant descriptions in steps S1004 - S1007, which will not be elaborated here.
[0224] In this way, in a low - memory killing scenario, the electronic device can prevent the small - program empty process from being killed due to low memory, improve the survival rate of the small - program empty process, and then improve the utilization rate of the small - program empty process, shorten the startup time of the small - program, reduce the user's waiting time, and enhance the user's experience.
[0225] Optionally, before preserving the first small - program empty process alive, it includes: registering and preserving the first small - program empty process; the registration status of the small - program empty process is registered; adding the first small - program empty process to the preservation queue; setting the priority of the first small - program empty process; the priority of the first small - program empty process is higher than that of the empty process.
[0226] This process can refer to the relevant descriptions in steps S1001 - S1003, which will not be elaborated here.
[0227] In this way, in a low - memory killing scenario, the electronic device can prevent the small - program empty process from being killed due to low memory, improve the survival rate of the small - program empty process, and then improve the utilization rate of the small - program empty process, shorten the startup time of the small - program, reduce the user's waiting time, and enhance the user's experience.
[0228] Optionally, it further includes: when an operation on the first button is received in the first interface, pulling up the first small - program empty process and controlling the camera to perform image acquisition; when the image captured by the camera is the scannable code of the second target small - program, starting the second target small - program using the first small - program empty process; the second target small - program is different from the first target small - program.
[0229] This step can refer to the relevant descriptions in steps S1101 - S1103, which will not be elaborated here.
[0230] Comparing with the scenario shown in steps S1101 - S1103, it can be found that:
[0231] The first small - program empty process can be the empty process of the common components in the small - program loaded with the second application. Therefore, the first small - program empty process can be adapted to multiple small - programs under the second application. For example, both the first target small - program and the second target small - program are small - programs of the second application. The first small - program empty process can support accelerating the startup of the first target small - program, and the first small - program empty process can also support accelerating the startup of the second target small - program.
[0232] It can be understood that the mini-program startup method in the embodiments of the present application is based on the fact that the first mini-program empty process can be adapted to multiple mini-programs under the second application, and thus can be realized. The electronic device can use the first mini-program empty process to start any mini-program under the second application. In this way, the electronic device can shorten the time for starting the mini-program by preloading the mini-program empty process.
[0233] Optionally, it further includes: displaying a first interface of the first application, the first interface further including a second button for pulling up the third application for scanning a code; the third application is different from the second application; upon receiving an operation on the second button, pulling up the second mini-program empty process and controlling the camera to perform image acquisition; the second mini-program empty process is different from the first mini-program empty process; when the image captured by the camera is a scannable code of the third target mini-program, using the second mini-program empty process to start the third target mini-program, and the third target mini-program is different from the second target mini-program.
[0234] Among them, both the second button and the first button can be the scan button, but the application programs to which the first button and the second button belong are different. Exemplarily, Figure 1 in the interface shown in b of, there are two scan buttons displayed, and these two scan buttons can be the quick scan methods under different application programs. For example, the second application is the WeChat application, and the first button is the scan button of the WeChat application; the third application is the Alipay application, and the second button is the scan button of the Alipay application.
[0235] In addition, different application programs correspond to different mini-program empty processes. For example, the second application is the WeChat application, and the first mini-program empty process is appbrand0 and / or appbrand1; the third application is the Alipay application, and the second mini-program empty process is lite1.
[0236] In this way, the embodiments of the present application are not limited to the code scanning scenarios of a single application program, enriching the application scenarios of the mini-program startup method in the embodiments of the present application. In multiple code scanning scenarios, the time for starting the mini-program can be shortened, improving the user experience.
[0237] The mini-program startup method in the embodiments of the present application has been described above. Next, the apparatus for executing the above mini-program startup method provided by the embodiments of the present application will be described. Those skilled in the art can understand that the method and the apparatus can be combined and cited with each other, and the relevant apparatus provided by the embodiments of the present application can execute the steps in the above mini-program startup method.
[0238] As Figure 12As shown in the figure, the mini-program startup device 1200 can be used in a communication device, a circuit, a hardware component, or a chip. The mini-program startup device includes: a display unit 1201 and a processing unit 1202. Among them, the display unit 1201 is used to support the display steps executed by the mini-program startup device 1200; the processing unit 1202 is used to support the information processing steps executed by the mini-program startup device 1200.
[0239] In a possible implementation, the mini-program startup device 1200 may also include a communication unit 1203. Specifically, the communication unit is used to support the steps of data sending and data receiving executed by the mini-program startup device 1200. Among them, the communication unit 1203 may be an input or output interface, a pin, or a circuit, etc.
[0240] In a possible embodiment, the mini-program startup device may further include: a storage unit 1204. The processing unit 1202 and the storage unit 1204 are connected by a line. The storage unit 1204 may include one or more memories, and the memory may be a device or a component in one or more devices or circuits for storing programs or data. The storage unit 1204 may exist independently and be connected to the processing unit 1202 of the mini-program startup device through a communication line. The storage unit 1204 may also be integrated with the processing unit 1202.
[0241] The storage unit 1204 may store computer-executable instructions of the method in the terminal device, so that the processing unit 1202 executes the method in the above embodiments. The storage unit 1204 may be a register, a cache, or a RAM, etc. The storage unit 1204 may be integrated with the processing unit 1202. The storage unit 1204 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, and the storage unit 1204 may be independent of the processing unit 1202.
[0242] The mini-program startup method provided by the embodiments of the present application can be applied to an electronic device with communication functions. The electronic device includes a terminal device. The specific device form of the terminal device and the like can refer to the above relevant description, and will not be elaborated here.
[0243] The embodiments of the present application provide an electronic device, which includes: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the above method.
[0244] An embodiment of the present application provides a chip system. The chip system includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line. The at least one processor is configured to run a computer program or instruction to execute the above method. The implementation principle and technical effects are similar to those of the above related embodiments and will not be elaborated here.
[0245] An embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the above method is implemented. The method described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored on or transmitted over a computer-readable medium as one or more instructions or codes. The computer-readable medium can include a computer storage medium and a communication medium, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.
[0246] In a possible implementation, the computer-readable medium can include RAM, ROM, a compact disc read-only memory (CD-ROM), or other optical disc storage, a magnetic disk storage, or other magnetic storage device, or any other medium targeted to carry or store the required program code in the form of instructions or data structures and accessible by a computer. Moreover, any connection is properly referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technology such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technology such as infrared, radio, and microwave is included in the definition of the medium. As used herein, disk and optical disc include optical discs, laser discs, optical discs, Digital Versatile Discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs use lasers to optically reproduce data. The above combinations should also be included within the scope of the computer-readable medium.
[0247] An embodiment of the present application provides a computer program product. The computer program product includes a computer program that, when run, causes a computer to execute the above method.
[0248] Embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable devices to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate means for implementing the specified functions in one process Figure 1 or in multiple processes and / or blocks Figure 1 or means for implementing the specified functions in one block or multiple blocks.
[0249] In the above specific embodiments, the purpose, technical solution, and beneficial effects of the present invention have been further described in detail. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for starting a small program, characterized in that, Including: Display a first interface of a first application, the first interface including a first button for launching a second application to perform a code scan; When an operation on the first button is received, launch a first mini-program empty process and control the camera to perform image acquisition; the second application is different from the first application; When the image captured by the camera is a scannable code of a first target mini-program, start the first target mini-program by using the first mini-program empty process.
2. The method according to claim 1, characterized in that The first application includes a desktop application launcher, and the first interface includes a desktop and / or a negative first screen.
3. The method according to claim 1 or 2, characterized in that, The starting the first target mini-program by using the first mini-program empty process includes: Loading the content of the first target mini-program into the first mini-program empty process; wherein, the content of the first target mini-program includes basic information of the target mini-program and a code package of the target mini-program.
4. The method according to claim 3, wherein Before launching the first mini-program empty process, it further includes: Determine whether the first button is a button of a shortcut; When the first button is a button of a shortcut, obtain the name of the shortcut; The launching the first mini-program empty process includes: When the name of the shortcut is a preset name, launch the first mini-program empty process.
5. The method according to any one of claims 1-4, characterized in that, After launching the first mini-program empty process, it further includes: Keep the first mini-program empty process alive within a keep-alive time threshold.
6. The method according to claim 5, characterized in that, Keeping the first mini-program empty process alive includes: Query the registration status of the first mini-program empty process; the registration status is used to indicate whether to keep the process alive; When the registration status of the first mini-program empty process is registered, query the keep-alive time of the first mini-program empty process; When the keep-alive time of the first mini-program empty process is less than or equal to the keep-alive time threshold, query the system memory; When the system memory is greater than or equal to a system memory threshold, do not kill the first mini-program empty process.
7. The method according to claim 5, wherein Before keeping the first mini-program empty process alive, it includes: Register and keep the first mini-program empty process alive; the registration status of the mini-program empty process is registered; Add the first mini-program empty process to a keep-alive queue; Set the priority of the first mini-program empty process; the priority of the first mini-program empty process is higher than the priority of an empty process.
8. The method according to any one of claims 1-7, characterized in that, It further includes: When an operation on the first button is received in the first interface, launch the first mini-program empty process and control the camera to perform image acquisition; When the image captured by the camera is a scannable code of a second target mini-program, start the second target mini-program by using the first mini-program empty process; the second target mini-program is different from the first target mini-program.
9. The method according to any one of claims 1-8, characterized in that, It further includes: Display the first interface of the first application, the first interface further including a second button for launching a third application to perform a code scan; The third application is different from the second application; Upon receiving an operation on the second button, a second mini-program empty process is launched, and the camera is controlled to perform image acquisition; the second mini-program empty process is different from the first mini-program empty process; When the image captured by the camera is a scannable code of a third target mini-program, the third target mini-program is launched using the second mini-program empty process, and the third target mini-program is different from the second target mini-program.
10. An electronic device, characterized in that, Comprising: A processor and a memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, causing the electronic device to execute the method according to any one of claims 1-9.
11. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1-9 is implemented.
12. A chip system, characterized in that, Comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is configured to run a computer program or instructions to execute the method according to any one of claims 1-9.
13. A computer program product, characterized in that, Comprising a computer program, when the computer program is run, causing the computer to execute the method according to any one of claims 1-9.
Citation Information
Patent Citations
Fast application association method and related device
CN111782989A
Applet starting control method and device
CN114090104A
Small program starting method, device and equipment and computer readable storage medium
CN114398094A
Code scanning method and terminal
CN114970589A
Method for preloading applet, electronic equipment and storage medium
CN116661882A