Page life cycle management method and device, equipment and storage medium
By distinguishing user interface components that need to be destroyed and do not need to be destroyed in page life cycle management, and binding and unbinding functional programs as life cycle observers, the memory leakage problem during page minimization is solved, system resource recycling is optimized, and system performance is improved.
Patent Information
- Application Number
- CN202410009373.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-02
- Publication Date
- 2025-07-04
AI Technical Summary
When pages are minimized, the binding of the page life cycle to user interface components and functional programs in the prior art leads to excessive system resource usage and memory leakage.
By creating layout files and placeholder layout objects, distinguish user interface components that need to be destroyed and do not need to be destroyed, and use functional programs as life cycle observers of application components to perform binding and unbinding operations to optimize resource recycling.
It effectively avoids memory leakage, optimizes system resource recycling, reduces invalid background operation, and improves system performance.
Smart Images

Figure CN120255884A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and in particular, to a method, apparatus, device, and storage medium for managing the page life cycle. Background Art
[0002] During the development of an application, the detection of the life cycle is of great significance for behavioral data such as data requests, page exposure duration statistics, and page reporting. The richer the perception of the life cycle state, the more accurately the above behavioral data can be obtained, and then the operation data can be deeply mined to improve the application product.
[0003] Currently, when the page state changes (such as the page being minimized), the page life cycle is usually packaged and processed together with the user interface components and interaction logic, or bound to the background service of the functional program called by the page. Under the above two solutions, when the page is minimized, the page still occupies a large amount of system resources.
[0004] Therefore, there is an urgent need for a solution to optimize the system resource occupancy when the page is minimized. Summary of the Invention
[0005] Embodiments of this application provide a method, apparatus, device, and storage medium for managing the page life cycle to optimize resource recycling when the page is minimized, thereby avoiding memory leaks.
[0006] In view of this, on the one hand, the present application provides a method for managing the life cycle of a page, comprising: in response to a first operation instruction, creating a first application component of a first page, the first application component being used to provide the first page and implement interactive operations of the first page, the first operation instruction being used to instruct the creation of the first page; creating a layout file and a placeholder layout object of the first application component, the layout file comprising a first user interface component set, the placeholder layout object being used to store a second user interface component set, wherein each user interface component in the first user interface component set is a user interface component of the first page minimized to the point where the first window is destroyed, and each user interface component in the second user interface component set is a user interface component of the first page minimized to the point where the first window is destroyed. A user interface component that is not destroyed when a page is minimized to a first window; creating a first object based on the first application component, the first object being used to indicate a function program called by the first page; establishing a binding relationship between the first object and the first application component, and setting the first object as a life cycle observer of the application component; storing the second user interface component set in the second application component in response to a second operation instruction, wherein the life cycle of the second application component is longer than that of the first application component, and the second operation instruction is used to instruct to minimize the first page to the first window; releasing the binding relationship between the first object and the first application component; and destroying the first application component and the first user interface component set.
[0007] On the other hand, the present application provides a page life cycle management device, including:
[0008] A creation module, configured to create a first application component of a first page in response to a first operation instruction, wherein the first application component is used to provide the first page and implement interactive operations on the first page, and the first operation instruction is used to instruct the creation of the first page; create a layout file of the first application component, wherein the layout file includes a placeholder layout object and a first user interface component set, wherein the placeholder layout object is used to store a second user interface component set, wherein each user interface component in the first user interface component set is a user interface component that is destroyed when the first page is minimized to a first window, and each user interface component in the second user interface component set is a user interface component that is not destroyed when the first page is minimized to a first window; create a first object based on the first application component, wherein the first object is used to indicate a function program called by the first page;
[0009] A binding module, used to establish a binding relationship between the first object and the first application component, and set the first object as a lifecycle observer of the application component;
[0010] a processing module, configured to store the second user interface component set from the placeholder layout object to a second application component in response to a second operation instruction, wherein the life cycle of the second application component is longer than the life cycle of the first application component, and the second operation instruction is used to instruct to minimize the first page;
[0011] An unbinding module, used to unbind the binding relationship between the first object and the first application component;
[0012] A destroying module is used to destroy the first application component and the first user interface component set.
[0013] In one possible design, in another implementation of another aspect of the embodiment of the present application, the creation module is used to create a third application component in response to a third operation instruction, the third application component is used to provide the first page and implement interactive operations of the first page, and the third operation instruction is used to instruct to restore the first page;
[0014] Create the first user interface component set based on the third application component;
[0015] Creating a layout file and a placeholder layout object of the third application component, wherein the layout file of the third application component includes the first user interface component set, and the placeholder layout object of the third application component is used to store the second user interface component set;
[0016] The binding module is used to establish a binding relationship between the first object and the third application component.
[0017] In a possible design, in another implementation of another aspect of the embodiment of the present application, a creation module is used to create a third application component in response to a third operation instruction, the third application component is used to provide the first page and implement the interactive operation of the first page, and the third operation instruction is used to instruct to restore the first page;
[0018] Creating a user interface component set of the first page based on the third application component, the user interface component set including the first user interface component set and the second user interface component set;
[0019] Creating a layout file and a placeholder layout object of the third application component, wherein the layout file of the third application component includes the first user interface component set, and the placeholder layout object of the third application component is used to store the second user interface component set;
[0020] The binding module is used to establish a binding relationship between the first object and the third application component.
[0021] In a possible design, in another implementation of another aspect of the embodiments of the present application, the creation module is configured to create a layout file of the first application component and the placeholder layout object, where the layout file includes a first set of user interface components and the occupied layout object, and the placeholder layout object is used to store a second set of user interface components;
[0022] Or,
[0023] The creation module is configured to create a layout file of the first application component and the placeholder layout object, where the layout file includes a first set of user interface components, the placeholder layout object is used to store a second set of user interface components, and the placeholder layout object is located in the second application component.
[0024] In a possible design, in another implementation of another aspect of the embodiments of the present application, when the layout file includes a first set of user interface components and the occupied layout object, the processing module is configured to, in response to the second operation instruction, remove the second set of user interface components from the placeholder layout object and store them in the second application component.
[0025] In a possible design, in another implementation of another aspect of the embodiments of the present application, the creation module is configured to obtain status information of the user interface components corresponding to the first application component, where the status information is used to indicate at least one of update information, power consumption information, and memory occupancy information of the user interface components;
[0026] Classify the user interface components into the first set of user interface components or the second set of user interface components according to the status information;
[0027] Place the second set of user interface components in the placeholder layout object and place the first set of user interface components in the layout file.
[0028] In a possible design, in another implementation of another aspect of the embodiments of the present application, the creation module is configured to, when the update information of the user interface component indicates that real-time update is not required, classify the user interface component into the first set of user interface components;
[0029] When the update information of the user interface component indicates that real-time update is required, classify the user interface component into the second set of user interface components.
[0030] In a possible design, in another implementation of another aspect of the embodiments of the present application, the creation module is configured to, when the power consumption information of the user interface component indicates that the power consumption of the user interface component is greater than the first threshold and the memory occupancy, classify the user interface component into the first set of user interface components;
[0031] When the power consumption information of the user interface component indicates that the power consumption of the user interface component is less than or equal to a first threshold, the user interface component is assigned to the second user interface component set.
[0032] In one possible design, in another implementation of another aspect of the embodiment of the present application, a module is created for attributing the user interface component to the first user interface component set when the memory occupation information of the user interface component indicates that the memory occupation of the user interface component is greater than a second threshold value;
[0033] When the memory occupation information of the user interface component indicates that the memory occupation amount of the user interface component is less than or equal to a second threshold, the user interface component is classified into the second user interface component set.
[0034] In one possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is used to display a second window in response to a fourth operation instruction, wherein the second window displays more user interface components than the first window, and the fourth operation instruction is used to instruct to expand the area of the first window.
[0035] In one possible design, in another implementation of another aspect of the embodiment of the present application, the unbinding module is used to release the binding relationship between the first object and the first application component in response to a fifth operation instruction, and the fifth operation instruction is used to instruct to terminate the functional program called by the first page;
[0036] A destroying module is used to destroy the first application component, the first user interface component set and the second user interface component set.
[0037] In one possible design, in another implementation of another aspect of the embodiment of the present application, the function program called by the first page is a voice call function program or a video call function program;
[0038] The first page includes a user interface component that is updated in real time. The user interface component that is updated in real time includes a user interface for initiating or hanging up a function program, a user interface for opening or blocking the other party's function, and a user interface for opening or blocking one's own function.
[0039] Another aspect of the present application provides a computer device, including: a memory, a processor, and a bus system;
[0040] Wherein, the memory is used to store programs;
[0041] The processor is used to execute the program in the memory, and the processor is used to execute the above-mentioned methods according to the instructions in the program code;
[0042] The bus system is used to connect a memory and a processor so that the memory and the processor can communicate with each other.
[0043] Another aspect of the present application provides a computer-readable storage medium storing instructions which, when run on a computer, cause the computer to execute the methods in the above aspects.
[0044] Another aspect of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to execute the methods provided in the above aspects.
[0045] From the above technical solutions, it can be seen that the embodiments of the present application have the following advantages: The functional program called by the first page acts as a lifecycle observer of the application components in the lifecycle of the first page, and performs corresponding binding and unbinding operations along with the lifecycle of the application components, so that the functional program called by the first page can still run when the lifecycle of the application components ends, and at the same time, the observation of the lifecycle by the functional program is released, thereby giving priority to the recycling of system resources, preventing the application components from occupying memory and causing memory leaks. At the same time, the user interface components corresponding to the first page are destroyed and retained according to requirements, so as to further give priority to the recycling of system resources and prevent ineffective background operation and waste of system resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a schematic diagram of an application scenario architecture of the method for managing the page lifecycle in the embodiments of the present application;
[0047] Figure 2 It is a schematic flowchart of the method for managing the page lifecycle in the embodiments of the present application;
[0048] Figure 3 It is a schematic diagram of an embodiment of the method for managing the page lifecycle in the embodiments of the present application;
[0049] Figure 4 It is a schematic diagram of an interface when the page in the embodiments of the present application is switched from the full-screen mode to the minimized mode;
[0050] Figure 5 It is another schematic diagram of the interface in the minimized mode in the embodiments of the present application;
[0051] Figure 6 It is a schematic diagram of an interface when the window in the minimized mode in the embodiments of the present application is enlarged;
[0052] Figure 7 Schematic diagram of an embodiment of the page lifecycle management device in an embodiment of the present application;
[0053] Figure 8 Schematic diagram of another embodiment of the page lifecycle management device in an embodiment of the present application;
[0054] Figure 9 Schematic diagram of another embodiment of the page lifecycle management device in an embodiment of the present application. Detailed implementation manners
[0055] The embodiments of the present application provide a method, device, equipment, and storage medium for managing the page lifecycle, which are used to optimize resource recycling when the page is minimized, so as to avoid memory leakage.
[0056] In the embodiments of the present application, the terms "first", "second", "third", "fourth", etc. (if any) in the specification, claims, and the above drawings of the present application are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "corresponding to" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device including a series of steps or units does not necessarily need to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0057] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of the overall module or unit including the function of that module or unit.
[0058] In the process of application development, life cycle detection is of great significance for behavioral data such as data requests, page exposure time statistics, and page reporting. The richer the life cycle state perception, the more accurately the above behavioral data can be obtained, and then the operation data can be deeply mined to improve the application product. At present, when the page state changes (such as page minimization), the page life cycle is usually packaged with the user interface components and interactive logic, or bound to the background service of the functional program called by the page. Under the above two schemes, when the page is minimized, the page still occupies a large amount of system resources. Therefore, there is an urgent need for a solution to optimize the system resource usage when the page is minimized.
[0059] In order to solve the above technical problems, the present application provides the following technical solutions: in response to a first operation instruction, a first application component of a first page is created, the first application component is used to provide the first page and implement interactive operations of the first page, and the first operation instruction is used to instruct the creation of the first page; a layout file and a placeholder layout object of the first application component are created, the layout file includes a first user interface component set, and the placeholder layout object is used to store a second user interface component set, wherein each user interface component in the first user interface component set is a user interface component of the first page minimized to the point where the first window is destroyed, and each user interface component in the second user interface component set is a user interface component of the first page minimized to the point where the first window is destroyed. A user interface component that is not destroyed when a page is minimized to a first window; a first object is created based on the first application component, the first object is used to indicate a function program called by the first page; a binding relationship is established between the first object and the first application component, and the first object is set as a life cycle observer of the application component; in response to a second operation instruction, the second user interface component set is stored in the second application component, wherein the life cycle of the second application component is longer than the life cycle of the first application component, and the second operation instruction is used to instruct to minimize the first page; the binding relationship between the first object and the first application component is released; and the first application component and the first user interface component set are destroyed. In this way, the function program called by the first page acts as a life cycle observer of the life cycle of the application component, and performs corresponding binding and unbinding operations with the life cycle of the application component, so that the function program called by the first page can still run at the end of the life cycle of the application component, and at the same time, the function program's observation of the life cycle is released, thereby giving priority to the recovery of system resources, avoiding the application component occupying memory and causing memory leakage. At the same time, the user interface component corresponding to the first page is destroyed and retained as required, so that system resource recovery can be further given priority, avoiding invalid background operation and wasting system resources.
[0060] A method, device, device, and storage medium for managing the page life cycle provided by an embodiment of the present application are used to optimize resource recovery when the page is minimized, thereby avoiding memory leakage. The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The electronic device provided by the embodiment of the present application can be implemented as various types of user terminals or as a server.
[0061] The electronic device runs the method for managing the page life cycle provided by the embodiment of the present application, which is used to optimize resource recovery when the page is minimized, thereby avoiding memory leakage.
[0062] The above solution can be applied to many application development fields, including the development processes of communication software, social software, and other applications. When using the method for managing the page life cycle provided by the embodiment of the present application to help users develop applications, this method can be implemented as an independent online application and installed in the computer device or background server used by the user, facilitating the user to use this program to manage the page life cycle of the application.
[0063] In an exemplary solution, the method for managing the page life cycle can be applied to game application development. For example, in a game scenario, if a voice call function or a video call function is added to the game application, during the game, when the voice call function is enabled and the page of the voice call function is minimized, it is convenient for the user to play the game while maintaining the voice call. At this time, the application components (i.e., Activity) under the full-screen interface of the voice call function and a part of the user interface components (i.e., view) can be released, so that the voice call function releases more system resources, thereby ensuring the running performance of the game.
[0064] In an exemplary solution, the method for managing the page life cycle can be applied to application development. For example, adding the method for managing the page life cycle to a social software enables the release of the application components (i.e., Activity) under the full-screen interface of the voice call function and a part of the user interface components (i.e., view) when the page of the voice call function in the social software is minimized.
[0065] Among them, in the development of the Android system, an Activity is an application component that provides a user interface and can respond to user interaction events such as clicks and swipes. Each Activity has an associated life cycle, which is defined by a series of callback methods. These methods allow the program to know what kind of interaction the user is having with the Activity and when the Activity operation should be paused, data should be saved, or a response should be made to the user's interaction.
[0066] In Android development, a View is all user interface components (such as buttons, text boxes, picture boxes, etc.). A view can be regarded as a rectangular area on the screen, which is responsible for drawing and event handling. Each view occupies a certain space on the screen and can interact with users.
[0067] See Figure 1 , Figure 1It is an optional architecture diagram in an application scenario of the page lifecycle management solution provided by the embodiments of the present application. To implement a page lifecycle management solution, the terminal device 100 is connected to the server 300 through the network 200, and the server 300 is connected to the database 400. The network 200 can be a wide area network, a local area network, or a combination of both. The client for implementing the page lifecycle management solution is deployed on the terminal device 100. The client can run on the terminal device 100 in the form of a browser or in the form of an independent application (APP), etc. The specific display form of the client is not limited here. The server 300 involved in the present application can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The terminal device 100 can be a smart phone, a tablet computer, a laptop computer, a handheld computer, a personal computer, a smart TV, a smart watch, a vehicle-mounted device, a wearable device, a smart voice interaction device, a smart home appliance, an aircraft, etc., but is not limited thereto. The terminal device 100 and the server 300 can be directly or indirectly connected through the network 200 by wired or wireless communication methods, and the present application does not limit this here. The number of the server 300 and the terminal device 100 is also not limited. The solution provided by the present application can be completed independently by the terminal device 100, can be completed independently by the server 300, or can be completed by the cooperation of the terminal device 100 and the server 300. The present application does not make specific limitations on this. Among them, the database 400 can be regarded as an electronic filing cabinet in short - a place for storing electronic files. Users can perform operations such as adding, querying, updating, and deleting data in the files. The so - called "database" is a data set stored together in a certain way, shared by multiple users, with as little redundancy as possible, and independent of application programs. The Database Management System (DBMS) is a computer software system designed to manage the database and generally has basic functions such as storage, interception, security guarantee, and backup.Database management systems can be classified according to the database models they support, such as relational, Extensible Markup Language (XML); or according to the types of computers they support, such as server clusters, mobile phones; or according to the query languages used, such as Structured Query Language (SQL), XQuery; or according to the performance impulse focus, such as maximum scale, highest running speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories. For example, they can support multiple query languages at the same time. In this application, the database 400 can be used to store program codes during the operation of the application, as well as data such as called application components and user interface components. Of course, the storage locations of the program codes during the operation of the application, as well as data such as called application components and user interface components, are not limited to the database. For example, they can also be stored in the terminal device 100, blockchain, or the distributed file system of the server 300, etc.
[0068] It can be understood that the method for managing the page life cycle provided in this application can be executed by the server 300; correspondingly, the device for managing the page life cycle can be set in the server 300. Of course, the method for managing the page life cycle provided in this application can also be executed by the terminal device 100; correspondingly, the device for managing the page life cycle can be set in the terminal device 100. Similarly, the method for managing the page life cycle provided in this application can also be jointly executed by the terminal device 100 and the server 300; correspondingly, the device for managing the page life cycle can be set in the terminal device 100 and the server 300. The embodiments of this application do not make any limitations on the device form for executing the method for managing the page life cycle.
[0069] Based on the above description, the method for managing the page life cycle in this application will be described below with Figure 2 the following schematic flow diagram:
[0070] As Figure 2 shown, after a function program (such as a voice call function) is called in response to a user's operation, an initialization page will be displayed (at this time, the initialization page is usually in full-screen mode). When generating this initialization page, it is necessary to first create a first Activity, and at the same time, layout the user interface components (i.e., views) managed by this first Activity according to whether they need to be destroyed when minimized, and generate the corresponding layout file; finally, create the voice call function object based on this first Activity; and bind the voice call function object to this first Activity, so that the voice call function object serves as the life cycle observer of this first Activity.
[0071] In the next stage, if switching from the full-screen mode to the minimized mode, it is necessary to save the views retained by the first page to the global location of the application, then unbind the first Activity from its corresponding lifecycle observer (i.e., the voice call function object), and finally destroy the Activity and the views to be destroyed.
[0072] In the next stage, if switching from the minimized mode to the full-screen mode, it is necessary to recreate the Activity (denoted as the second Activity here), simultaneously recreate the views destroyed in the minimized mode, layout the user interface components (i.e., views) managed by the second Activity according to whether they need to be destroyed when minimized, and generate the corresponding layout file; finally, create the voice call function object based on the second Activity; and bind the voice call function object to the second Activity, making the voice call function object act as the lifecycle observer of the second Activity.
[0073] If in the last stage, if it is necessary to end the voice call, it is necessary to unbind the second Activity from its corresponding lifecycle observer (i.e., the voice call function object); finally, destroy the second Activity and all its views.
[0074] It should be understood that ending the voice call can be before minimizing, that is, ending the voice call without performing the minimization operation throughout the process. At this time, it is necessary to unbind the first Activity from its corresponding lifecycle observer (i.e., the voice call function object); finally, destroy the first Activity and all its views.
[0075] In another implementable solution, on the premise that the minimized mode has the function of ending the voice call, if ending the voice call, it is only necessary to directly destroy the views that were not destroyed during minimization.
[0076] It can be understood that in the specific implementation of this application, it involves relevant data such as code programs and debugging programs. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.
[0077] Combined with the above introduction, the method for managing the page lifecycle in this application will be introduced below. Please refer to Figure 3 , an embodiment of the method for managing the page lifecycle in the embodiments of this application includes:
[0078] 301. In response to a first operation instruction, create a first application component for a first page, where the first application component is used to provide the first page and implement the interaction operations of the first page, and the first operation instruction is used to indicate the creation of the first page.
[0079] In this embodiment, during the running process of the application, the Activity class is a key component of the Android application, and the startup and combination methods of the Activity are the basic components of the application. In the programming paradigm, the application is started through the main() method, while the Android system is different. It will call specific callback methods corresponding to specific stages of its life cycle to start the code in the Activity instance. Therefore, during the running process of the application, in response to the first operation instruction in its operation interface, the corresponding function will be called to run the function program provided by the application; at the same time, the initialization page corresponding to the function program (i.e., the first page) will be rendered. During the process of rendering the first page, the first application component (i.e., Activity) of the first page will be created, and then the user interface components of the first page and the function program called by the first page will be interactively connected based on the first application component. For example, when the function program called by the first page is a voice call, the overall voice call will consist of the Activity, the user interface component (UI), and the voice call function.
[0080] It should be understood that the Activity also provides a user interface that can respond to user interaction events such as clicks and swipes. Each Activity has an associated life cycle, which is defined by a series of callback methods. These methods allow the program to know what kind of interaction the user is having with the Activity, and when the Activity operation should be paused, data should be saved, or a response should be made to the user's interaction.
[0081] 302. Create a layout file and a placeholder layout object for the first application component. The layout file includes a first set of user interface components, and the placeholder layout object is used to store a second set of user interface components. Among them, each user interface component in the first set of user interface components is a user interface component that is destroyed when the first page is minimized to the first window, and each user interface component in the second set of user interface components is a user interface component that is not destroyed when the first page is minimized to the first window.
[0082] In this embodiment, in order to perform a minimized configuration on the user interface components of the first page, a layout file for the first application component can be created to distinguish the user interface components that are destroyed during minimization from the user interface components that are not destroyed during minimization.
[0083] The specific implementation method can be as follows:
[0084] In one implementation solution, the layout file is created based on the first application component. At this time, the layout file includes a first set of user interface components and a placeholder layout object, and the placeholder layout object is used to store a second set of user interface components. Among them, each user interface component in the first set of user interface components is a user interface component that is destroyed when the first page is minimized to the first window, and each user interface component in the second set of user interface components is a user interface component that is not destroyed when the first page is minimized to the first window.
[0085] In another implementation solution, the layout file is created based on the first application component. At this time, the layout file includes a first set of user interface components, and the placeholder layout object is used to store a second set of user interface components, and the placeholder layout object is stored in a global location. Among them, each user interface component in the first set of user interface components is a user interface component that is destroyed when the first page is minimized to the first window, and each user interface component in the second set of user interface components is a user interface component that is not destroyed when the first page is minimized to the first window.
[0086] Specifically, when creating the layout file, the following solution can be adopted: Obtain the status information of the user interface components corresponding to the first application component, and the status information is used to indicate at least one of the update information, power consumption information, and memory occupancy information of the user interface components; classify the user interface components into the first set of user interface components or the second set of user interface components according to the status information; place the second set of user interface components in the placeholder layout object; generate the layout file according to the first set of user interface components and the placeholder layout object.
[0087] In one implementation method, when the update information of the user interface component indicates that real-time update is not required, the user interface component is classified into the first set of user interface components;
[0088] When the update information of the user interface component indicates that real-time update is required, the user interface component is classified into the second set of user interface components.
[0089] In another implementation method, when the power consumption information of the user interface component indicates that the power consumption of the user interface component is greater than the first threshold, the user interface component is classified into the first set of user interface components;
[0090] When the power consumption information of the user interface component indicates that the power consumption of the user interface component is less than or equal to the first threshold, the user interface component is classified into the second set of user interface components.
[0091] In another implementation, when the memory occupancy information of the user interface component indicates that the memory occupancy of the user interface component is greater than the second threshold, the user interface component is classified into the first set of user interface components;
[0092] When the memory occupancy information of the user interface component indicates that the memory occupancy of the user interface component is less than or equal to the second threshold, the user interface component is classified into the second set of user interface components.
[0093] It can be understood that the above judgment process can be used comprehensively or any one of them can be selected alone, and specific limitations are not made here. As long as the function program can run after setting.
[0094] The following is an example to illustrate. Suppose the first page calls the voice call function, the first application component is the first Activity, and the placeholder layout object is FrameLayout(). When the Activity onCreate() method is called, the activity setContentView(View view) method can be used to set the layout file. For example, the layout file generated by calling activity setContentView(View view) can be as follows: (view1, view2, view5, FrameLayout(view3, view4)). At this time, the view1, view2, and view5 are user interface components that are destroyed when minimized, and the view3 and view4 are user interface components that are not destroyed when minimized.
[0095] Among them, setContentView is to set the display interface of an Activity. Using setContentView can dynamically switch the displayed View in the Activity. In this way, different interfaces can be displayed without multiple Activities. Therefore, there is no need to transfer data between Activities, and variables can be directly referenced. It should be understood that setContentView is a polymorphic method. First, the layout file can be introduced as a View object using LayoutInflater, and then the view can be switched through the setContentView(View view) method.
[0096] FrameLayout can be the simplest one among the six layouts in an Android application. This layout directly creates a blank area on the screen. When adding controls (i.e., views) to it, the controls will be default placed at the upper left corner of this area. And there is no positioning method in this layout way, so it has not many application scenarios. The size of the FrameLayout is determined by the largest child control. If the sizes of the controls are the same, then only the topmost component can be seen at the same time. The subsequently added controls will cover the previous one. Also, although the controls are default placed at the upper left corner, the position can also be specified to other positions through the layout_gravity attribute.
[0097] 303. Create a first object based on the first application component, and this first object is used to indicate the function program called by the first page.
[0098] In this embodiment, after creating the first page, a class object of the function program called by the first page can be created based on the first application component, that is, create a first object that has a mapping relationship with the function program, and at the same time store this first object at the global position of the application program. This can ensure that the life cycle of the first object is the same as that of the function program.
[0099] In an exemplary solution, when the function called by the first page is the voice call function and the first application component is the first Activity, the voice call function object (MediaRoom) can be created through the activity onCreate() method and the voice call function object can be stored at the global position.
[0100] 304. Establish a binding relationship between the first object and the first application component, and set the first object as the life cycle observer of the first application component.
[0101] In this embodiment, after creating the object corresponding to the function program, the object is bound to the first application component, so that the object is the life cycle observer of the application component.
[0102] In an exemplary scenario, when the first page calls a voice call function and the first application component is the first Activity, a voice call function object (MediaRoom) is created through the activity onCreate() method and the voice call function object is stored in a global location; then the MediaRoom is bound to the first Activity through the (activity as FragmentActivity).lifecycle.addObserver(LifecycleObserver observer) method, and the MediaRoom is set as the lifecycle observer of the first Activity.
[0103] 305. In response to a second operation instruction, store the second user interface component set into a second application component, wherein a life cycle of the second application component is longer than a life cycle of the first application component, and the second operation instruction is used to instruct minimization of the first page.
[0104] In this embodiment, the above steps 301 to 304 complete the full-screen mode of the first page. When the "minimize" control is clicked on the first page, the second user interface component set of the first application component will be stored in the second application component in response to the "minimize" operation instruction. At this time, the life cycle of the second application component is longer than the life cycle of the first application component.
[0105] Optionally, in this embodiment, if the placeholder layout object storing the second user interface component set is included in the layout file of the first application component, then in this step the second user interface component set needs to be removed from the placeholder layout object first and then stored in the second application component.
[0106] In an exemplary solution, assuming that the first page calls the voice call function, the first application component is the first Activity, the placeholder layout object is FrameLayout(), and the second application component is a global component, the removeVIew() method can be used to remove the view stored in the FrameLayout() first, and then store it in the global position of the application. For example, for the FrameLayout(view3, view4), removeVIew(view3, view4) is used first to remove view3 and view4 from the FrameLayout(), and then store view3 and view4 in the global position.
[0107] 306. Release the binding relationship between the first object and the first application component.
[0108] In this embodiment, after storing the non-destructible user interface component in the second application component, the first object is then unbound from the first application component, so that the first application component can be destroyed while continuing to run the functional program indicated by the first object.
[0109] In an exemplary solution, when the voice call function is called on the first page and the first application component is the first Activity, a voice call function object (MediaRoom) is created through the activity onCreate() method and the voice call function object is stored in a global location; then the MediaRoom is bound to the first Activity through the (activity as FragmentActivity).lifecycle.addObserver(LifecycleObserver observer) method, and the MediaRoom is set as a lifecycle observer of the first Activity; then in this step, the MediaRoom can be unbound from the first Activity using the (activity as FragmentActivity).lifecycle.removeObserver(LifecycleObserver observer) method.
[0110] 307. Destroy the first application component and the first set of user interface components.
[0111] In this embodiment, after storing the second set of user interface components and unbinding the first object from the first application component, relevant functions can be called to destroy the first application component and the first set of user interface components.
[0112] In an exemplary solution, when the voice call function is called on the first page and the first application component is the first Activity, finish() can be called to destroy the first Activity.
[0113] It should be understood that after this step, if it is necessary to restore the first page, steps 301 to 304 can be re-executed. In one implementation, before executing step 302, it is also necessary to newly create the first page with the minimized destructible user interface components (i.e., newly create each user interface component in the first set of user interface components).
[0114] In another implementation, the second set of user interface components can also be discarded first, and then when executing step 301, all user interface components are newly created, and then steps 301 to 304 are executed.
[0115] It can be understood that when ending the function program of the first page call, if in full-screen mode, the first object can be unbound from the application component first; finally, the application component and all user interface components are destroyed.
[0116] If the function program can be ended in minimized mode, the function program can be directly interrupted, and then the second set of user interface components can be destroyed.
[0117] In an exemplary solution, the function called on the first page is a voice call function, and the first application component is the first Activity. If the voice is exited when the initialization page, that is, the first page, is displayed, the MediaRoom and the first Activity can be directly unbound by the (activity as FragmentActivity).lifecycle.removeObserver(LifecycleObserver observer) method, and then the first Activity and all user interface components corresponding to the first Activity are destroyed using finish(). If the voice call is exited when the first page is minimized, the user interface components that were not destroyed during minimization are destroyed using finish().
[0118] From the above description, it can be seen that in the technical solution provided by this application, the function program called on the first page serves as a lifecycle observer of the lifecycle of the application component of the first page, and corresponding binding and unbinding operations are performed along with the lifecycle of the application component, so that the function program called on the first page can still run when the lifecycle of the application component ends, and at the same time, the observation of the lifecycle by the function program is released, thereby giving priority to the recycling of system resources, avoiding the application component from occupying memory and causing memory leaks. At the same time, the user interface components corresponding to the first page are destroyed and retained according to requirements, which can further give priority to the recycling of system resources, avoid invalid background operation, and waste system resources.
[0119] The following describes the technical solution provided by this application from the product side. For details, please refer to Figures 4 to 6 .
[0120] As Figure 4 shown, when making a voice call, the first page will display various user interface components. These can include user interface components with real-time updates (such as Figure 4 the control "07:30" for displaying the call duration shown in the left figure in Figure 4 ), user interface components with a large memory footprint (such as Figure 4The hang-up control shown in the left-middle figure ("Phone"), the user interface component for enabling / disabling the other party's voice function (such as Figure 4 the voice shielding control for the other party shown in the left-middle figure ("Speaker"), the user interface component for enabling / disabling one's own voice function (such as Figure 4 the voice shielding control for oneself shown in the left-middle figure ("Microphone").
[0121] After clicking the "Minimize" control, it can be shown as Figure 4 shown in the right-middle figure, that is, the voice call interface is presented in window form on top of another interface, and at the same time, some user interface components can also be shown.
[0122] After minimization, the interface window of this voice call can be moved accordingly, as Figure 5 shown, moving this interface window from the upper right corner to the middle on the right side. At the same time, other operations can also be performed on this application, without affecting this voice call function.
[0123] At the same time, the interface window of this voice call can also be enlarged accordingly. As Figure 6 shown, enlarging this interface window, and then the enlarged interface window can also show more user interface components.
[0124] The management device for the page life cycle in this application will be described in detail below. Please refer to Figure 7 , Figure 7 which is a schematic diagram of an embodiment of the management device for the page life cycle in an embodiment of this application. The management device 20 for the page life cycle includes:
[0125] A creation module 201, which is used to create a first application component of a first page in response to a first operation instruction. This first application component is used to provide this first page and implement the interaction operation of this first page. This first operation instruction is used to indicate the creation of this first page; create a layout file for this first application component. This layout file includes a placeholder layout object and a first set of user interface components. This placeholder layout object is used to store a second set of user interface components. Among them, each user interface component in this first set of user interface components is a user interface component of this first page from minimization to the destruction of the first window, and each user interface component in this second set of user interface components is a user interface component that is not destroyed when this first page is minimized to the first window; create a first object based on this first application component. This first object is used to indicate the function program called by this first page;
[0126] A binding module 202, which is used to establish a binding relationship between this first object and this first application component, and set this first object as the life cycle observer of this application component;
[0127] A processing module 203, configured to, in response to a second operation instruction, store the second user interface component set from the placeholder layout object to a second application component, where the life cycle of the second application component is longer than that of the first application component, and the second operation instruction is used to indicate minimizing the first page to the first window.
[0128] An unbinding module 204, configured to unbind the first object from the first application component.
[0129] A destruction module 205, configured to destroy the first application component and the first user interface component set.
[0130] In an embodiment of the present application, a page life cycle management device is provided. By using the above device, a function program called by a first page acts as a life cycle observer of an application component, and corresponding binding and unbinding operations are performed along with the life cycle of the application component, so that the function program called by the first page can still run when the life cycle of the application component ends, and at the same time, the observation of the life cycle by the function program is released, thereby giving priority to the recovery of system resources, avoiding the application component occupying memory and causing memory leakage. At the same time, the user interface components corresponding to the first page are destroyed and retained according to requirements, so that the recovery of system resources can be further prioritized, avoiding invalid background operation and wasting system resources.
[0131] Optionally, based on the corresponding embodiment above, in another embodiment of the page life cycle management device 20 provided in the embodiment of the present application, Figure 7 The creation module 201 is configured to, in response to a third operation instruction, create a third application component, where the third application component is used to provide the first page and implement the interaction operation of the first page, and the third operation instruction is used to indicate restoring the first page; create the first user interface component set based on the third application component; create a layout file and a placeholder layout object of the third application component, where the layout file of the third application component includes the first user interface component set, and the placeholder layout object of the third application component is used to store a second user interface component set.
[0132] The binding module 202 is configured to establish a binding relationship between the first object and the third application component.
[0133] The binding module 202 is configured to establish a binding relationship between the first object and the third application component.
[0134] In an embodiment of the present application, a management device for page life cycle is provided. By using the above device, when restoring from a first window to the first page, since the previous application component and the first set of user interface components of the first page have been destroyed, it is necessary to reconstruct the application component and the first set of user interface components, and set the corresponding layout file and placeholder layout object; then bind the first object and the third application component again. That is, binding and unbinding are performed according to the life cycle of the application component and the functional program called by the first page, thereby giving priority to the recycling of system resources, avoiding the application component occupying memory and causing memory leakage. At the same time, the user interface components corresponding to the first page are destroyed and retained according to requirements, so as to further give priority to the recycling of system resources, avoid ineffective background operation and waste of system resources.
[0135] Optionally, based on the corresponding embodiment above, Figure 7 In another embodiment of the page life cycle management device 20 provided in the embodiment of the present application, a creation module 201 is configured to create a third application component in response to a third operation instruction. The third application component is used to provide the first page and implement the interaction operation of the first page, and the third operation instruction is used to indicate restoring the first page; create a set of user interface components of the first page based on the third application component. The set of user interface components includes the first set of user interface components and the second set of user interface components; create a layout file and a placeholder layout object for the third application component. The layout file of the third application component includes the first set of user interface components, and the placeholder layout object of the third application component is used to store the second set of user interface components;
[0136] The binding module 202 is configured to establish a binding relationship between the first object and the third application component.
[0137] In an embodiment of the present application, a management device for page life cycle is provided. By using the above device, when restoring from a first window to the first page, since the previous application component and all user interface components corresponding to the application component of the first page have been destroyed, it is necessary to reconstruct the application component and all user interface components corresponding to the application component, and set the corresponding layout file and placeholder layout object; then bind the first object and the third application component again. This can reduce the operation on the user interface components that were not destroyed during minimization. At the same time, binding and unbinding are performed according to the life cycle of the application component and the functional program called by the first page, thereby giving priority to the recycling of system resources, avoiding the application component occupying memory and causing memory leakage. At the same time, the user interface components corresponding to the first page are destroyed and retained according to requirements, so as to further give priority to the recycling of system resources, avoid ineffective background operation and waste of system resources.
[0138] Optionally, based on the above Figure 7Based on the corresponding embodiments, in another embodiment of the page lifecycle management device 20 provided by the embodiments of the present application,
[0139] The creation module 201 is configured to create a layout file of the first application component and the placeholder layout object, where the layout file includes a first set of user interface components and the occupancy layout object, and the placeholder layout object is used to store a second set of user interface components;
[0140] Or,
[0141] The creation module 201 is configured to create a layout file of the first application component and the placeholder layout object, where the layout file includes a first set of user interface components, the placeholder layout object is used to store a second set of user interface components, and the placeholder layout object is located in the second application component.
[0142] In the embodiments of the present application, a page lifecycle management device is provided. By using the above device, the user interface components corresponding to the first page are destroyed and retained according to requirements, so that the system resource recycling can be further prioritized, avoiding ineffective background operation and wasting system resources. At the same time, multiple implementation methods are provided, which can increase the feasibility of the solution.
[0143] Optionally, based on the corresponding embodiments above, Figure 7 In another embodiment of the page lifecycle management device 20 provided by the embodiments of the present application,
[0144] When the layout file includes a first set of user interface components and the occupancy layout object, the processing module 203 is configured to, in response to the second operation instruction, remove the second set of user interface components from the placeholder layout object and store them in the second application component.
[0145] In the embodiments of the present application, a page lifecycle management device is provided. By using the above device, by moving and storing the second set of user interface components stored in the occupancy layout object to the second application component of the functional program, the user interface components in the second set of user interface components are prevented from being destroyed along with the destruction of the first application component, thereby ensuring the normal operation of the functional program.
[0146] Optionally, based on the corresponding embodiments above, Figure 7 In another embodiment of the page lifecycle management device 20 provided by the embodiments of the present application, the processing module 203 is configured to, in response to a fourth operation instruction, display a second window, and the user interface components displayed in the second window are more than those in the first window, and the fourth operation instruction is used to instruct to expand the area of the first window.
[0147] In an embodiment of the present application, a device for managing the page life cycle is provided. By using the above device, after the first window obtained by minimizing the first page, the display area of the first window is adjusted according to requirements, so that the first window can display more user interface components, achieving a better operation purpose.
[0148] Optionally, based on the corresponding embodiment above, in another embodiment of the page life cycle management device 20 provided in the embodiment of the present application, a creation module 201 is used to obtain the status information of the user interface components corresponding to the first application component, and the status information is used to indicate at least one of the update information, power consumption information, and memory occupancy information of the user interface components; Figure 7 According to the status information, the user interface components are classified into the first user interface component set or the second user interface component set;
[0149] The second user interface component set is placed in the placeholder layout object, and the first user interface component set is placed in the layout file.
[0150] In an embodiment of the present application, a device for managing the page life cycle is provided. By using the above device, according to the status information of the user interface components, the user interface components corresponding to the first page are destroyed and retained as needed, so that the destroyed and retained user interface components can be configured and processed accordingly, thereby giving priority to system resource recovery and avoiding invalid background operation and wasting system resources.
[0151] Optionally, based on the corresponding embodiment above, in another embodiment of the page life cycle management device 20 provided in the embodiment of the present application,
[0152] The creation module 201 is used to classify the user interface components into the first user interface component set when the update information of the user interface components indicates that real-time update is not required; Figure 7 When the update information of the user interface components indicates that real-time update is required, the user interface components are classified into the second user interface component set.
[0153] In an embodiment of the present application, a device for managing the page life cycle is provided. By using the above device, when the user interface component is a real-time update component, it is determined that the user interface component does not need to be destroyed, and when the user interface component is a non-real-time update component, it is determined that the user interface component needs to be destroyed, so as to ensure that user data is synchronized in a timely manner as much as possible and provide a better user experience.
[0154] Optionally, based on the corresponding embodiment above,
[0155] In an embodiment of the present application, a device for managing the page life cycle is provided. By using the above device, when the user interface component is a real-time update component, it is determined that the user interface component does not need to be destroyed, and when the user interface component is a non-real-time update component, it is determined that the user interface component needs to be destroyed, so as to ensure that user data is synchronized in a timely manner as much as possible and provide a better user experience.
[0156] Optionally, based on the corresponding embodiment above, Figure 7Based on the corresponding embodiment, in another embodiment of the page lifecycle management device 20 provided in the embodiments of the present application,
[0157] A creation module 201, configured to classify the user interface component into the first user interface component set when the power consumption information of the user interface component indicates that the power consumption of the user interface component is greater than a first threshold and the memory occupancy;
[0158] When the power consumption information of the user interface component indicates that the power consumption of the user interface component is less than or equal to the first threshold, classify the user interface component into the second user interface component set.
[0159] In the embodiments of the present application, a page lifecycle management device is provided. By using the above device, when the power consumption of a user interface component is large, it is determined that the user interface component needs to be destroyed, and when the power consumption of the user interface component is small, it is determined that the user interface component does not need to be destroyed. In this way, user interface components with large power consumption can be destroyed as much as possible, so as to reduce the power consumption of the application program when running in the background, and further improve the performance of the application program.
[0160] Optionally, based on the corresponding embodiment above, in another embodiment of the page lifecycle management device 20 provided in the embodiments of the present application, Figure 7 Based on the corresponding embodiment, in another embodiment of the page lifecycle management device 20 provided in the embodiments of the present application,
[0161] A creation module 201, configured to classify the user interface component into the first user interface component set when the memory occupancy information of the user interface component indicates that the memory occupancy of the user interface component is greater than a second threshold and the memory occupancy;
[0162] When the memory occupancy information of the user interface component indicates that the memory occupancy of the user interface component is less than or equal to the second threshold, classify the user interface component into the second user interface component set.
[0163] In the embodiments of the present application, a page lifecycle management device is provided. By using the above device, when the memory occupancy of a user interface component is large, it is determined that the user interface component needs to be destroyed, and when the memory occupancy of the user interface component is small, it is determined that the user interface component does not need to be destroyed. In this way, user interface components with large memory occupancy can be destroyed as much as possible, so as to recover system resources as much as possible when running in the background, avoid memory leakage of the application program, and further improve the performance of the application program.
[0164] Optionally, based on the corresponding embodiment above, in another embodiment of the page lifecycle management device 20 provided in the embodiments of the present application, Figure 7 Based on the corresponding embodiment, in another embodiment of the page lifecycle management device 20 provided in the embodiments of the present application,
[0165] An unbinding module 204, configured to release the binding relationship between the first object and the first application component in response to a fifth operation instruction, wherein the fifth operation instruction is used to instruct to terminate the function program called by the first page;
[0166] The destroying module 205 is used to destroy the first application component, the first user interface component set and the second user interface component set.
[0167] In an embodiment of the present application, a page life cycle management device is provided. By using the above device, when the function program is interrupted, the application component corresponding to the first page and the user interface component are directly destroyed, which can effectively realize the recycling of system resources, thereby avoiding memory leakage and improving the performance of the application.
[0168] Optionally, in the above Figure 7 Based on the corresponding embodiment, in another embodiment of the page life cycle management device 20 provided in the embodiment of the present application,
[0169] The function program called by the first page is a voice call function program or a video call function program;
[0170] The first page includes a user interface component that is updated in real time. The user interface component that is updated in real time includes a user interface for initiating or hanging up a function program, a user interface for opening or blocking the other party's function, and a user interface for opening or blocking one's own function.
[0171] In the embodiment of the present application, a device for managing the page life cycle is provided. The device is used to provide an application scenario of the solution and increase the feasibility of the solution.
[0172] The page life cycle management device provided in this application can be a server, see Figure 8 , Figure 8 : is a schematic diagram of a server structure provided in an embodiment of the present application. The server 300 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 322 (for example, one or more processors) and memory 332, and one or more storage media 330 (for example, one or more mass storage devices) storing application programs 342 or data 344. Among them, the memory 332 and the storage medium 330 can be short-term storage or permanent storage. The program stored in the storage medium 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 322 can be configured to communicate with the storage medium 330 to execute a series of instruction operations in the storage medium 330 on the server 300.
[0173] The server 300 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM and so on.
[0174] The steps performed by the page lifecycle management device in the above embodiments may be based on the Figure 8 server structure shown.
[0175] The page lifecycle management device provided in this application may be a terminal device. Please refer to Figure 9 . For the sake of convenience of description, only the parts related to the embodiments of this application are shown. For the specific technical details not disclosed, please refer to the method part of the embodiments of this application. In the embodiments of this application, a smart phone is taken as an example of the terminal device for illustration:
[0176] Figure 9 The block diagram of a part of the structure of a smart phone related to the terminal device provided in the embodiments of this application is shown. Referring to Figure 9 , the smart phone includes: radio frequency (RF) circuit 410, memory 420, input unit 430, display unit 440, sensor 450, audio circuit 460, wireless fidelity (WiFi) module 470, processor 480, and power supply 490 and other components. Those skilled in the art can understand that Figure 9 the smart phone structure shown in does not constitute a limitation on the smart phone, and may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0177] Next, a specific introduction to each component of the smart phone will be given in conjunction with Figure 9 :
[0178] The RF circuit 410 can be used for receiving and transmitting information or signals during a call. Specifically, after receiving the downlink information from the base station, it is sent to the processor 480 for processing. Additionally, the uplink data designed is sent to the base station. Generally, the RF circuit 410 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 410 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0179] The memory 420 can be used to store software programs and modules. The processor 480 executes various functional applications and data processing of the smart phone by running the software programs and modules stored in the memory 420. The memory 420 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the smart phone (such as audio data, a phone book, etc.), etc. In addition, the memory 420 can include a high-speed random access memory and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0180] The input unit 430 can be used to receive input numeric or character information, and generate key signal inputs related to the user settings and function controls of the smart phone. Specifically, the input unit 430 can include a touch panel 431 and other input devices 432. The touch panel 431, also known as a touch screen, can collect touch operations of the user thereon or nearby (such as operations of the user using any suitable object or accessory such as a finger, a stylus, etc. on or near the touch panel 431), and drive corresponding connection devices according to a pre-set program. Optionally, the touch panel 431 can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 480, and can receive and execute commands sent by the processor 480. In addition, various types such as resistive, capacitive, infrared, and surface acoustic wave can be used to implement the touch panel 431. In addition to the touch panel 431, the input unit 430 can also include other input devices 432. Specifically, the other input devices 432 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, a joystick, etc.
[0181] The display unit 440 can be used to display information input by the user or information provided to the user and various menus of the smart phone. The display unit 440 can include a display panel 441. Optionally, the display panel 441 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 431 can cover the display panel 441. When the touch panel 431 detects a touch operation thereon or nearby, it is transmitted to the processor 480 to determine the type of touch event. Subsequently, the processor 480 provides a corresponding visual output on the display panel 441 according to the type of touch event. Although in Figure 9 the touch panel 431 and the display panel 441 are implemented as two independent components to realize the input and output functions of the smart phone, in some embodiments, the touch panel 431 and the display panel 441 can be integrated to realize the input and output functions of the smart phone.
[0182] The smart phone may also include at least one sensor 450, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. Among them, the ambient light sensor can adjust the brightness of the display panel 441 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 441 and / or the backlight when the smart phone is moved to the ear. As a kind of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary, and can be used for applications that identify the posture of the smart phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors that the smart phone can also be configured with, they will not be elaborated here.
[0183] The audio circuit 460, the speaker 461, and the microphone 462 can provide an audio interface between the user and the smart phone. The audio circuit 460 can transmit the electrical signal converted from the received audio data to the speaker 461, and the speaker 461 converts it into a sound signal for output; on the other hand, the microphone 462 converts the collected sound signal into an electrical signal, which is received by the audio circuit 460 and then converted into audio data. After the audio data is output to the processor 480 for processing, it is sent through the RF circuit 410 to, for example, another smart phone, or the audio data is output to the memory 420 for further processing.
[0184] WiFi belongs to short-range wireless transmission technology. The smart phone can help users send and receive emails, browse the web, and access streaming media through the WiFi module 470, which provides users with wireless broadband Internet access. Although Figure 9 the WiFi module 470 is shown, it can be understood that it does not belong to an essential component of the smart phone and can be omitted completely within the scope of not changing the essence of the invention according to needs.
[0185] The processor 480 is the control center of the smart phone, connecting various parts of the entire smart phone through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 420, and calling data stored in the memory 420, it executes various functions of the smart phone and processes data, thereby monitoring the smart phone as a whole. Optionally, the processor 480 may include one or more processing units; optionally, the processor 480 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above modem processor may not be integrated into the processor 480 either.
[0186] The smart phone further includes a power source 490 (such as a battery) for powering each component. Optionally, the power source can be logically connected to the processor 480 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system.
[0187] Although not shown, the smart phone may further include a camera, a Bluetooth module, etc., which will not be elaborated herein.
[0188] The steps performed by the management device of the page life cycle in the above embodiments may be based on the Figure 9 shown terminal device structure.
[0189] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When it runs on a computer, it causes the computer to execute the methods described in the foregoing various embodiments.
[0190] An embodiment of the present application further provides a computer program product including a program. When it runs on a computer, it causes the computer to execute the methods described in the foregoing various embodiments.
[0191] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be elaborated herein.
[0192] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0193] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0194] In addition, in each embodiment of the present application, each functional unit may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0195] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.
[0196] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of the present application.
Claims
1. A method for managing the page life cycle, characterized in that include: In response to a first operation instruction, creating a first application component of a first page, the first application component being used to provide the first page and implement interactive operations of the first page, the first operation instruction being used to instruct the creation of the first page; Creating a layout file and a placeholder layout object of the first application component, wherein the layout file includes a first user interface component set, and the placeholder layout object is used to store a second user interface component set, wherein each user interface component in the first user interface component set is a user interface component that is destroyed when the first page is minimized to a first window, and each user interface component in the second user interface component set is a user interface component that is not destroyed when the first page is minimized to a first window; Creating a first object based on the first application component, where the first object is used to indicate a function program called by the first page; Establishing a binding relationship between the first object and the first application component, and setting the first object as a lifecycle observer of the application component; In response to a second operation instruction, storing the second user interface component set in a second application component, wherein the life cycle of the second application component is longer than the life cycle of the first application component, and the second operation instruction is used to instruct to minimize the first page to the first window; Unbinding the first object from the first application component; The first application component and the first user interface component set are destroyed.
2. The method according to claim 1, wherein After destroying the first application component and the first user interface component set, the method further includes: In response to a third operation instruction, creating a third application component, the third application component being used to provide the first page and implement interactive operations of the first page, the third operation instruction being used to instruct to restore the first page; Creating the first user interface component set based on the third application component; Creating a layout file and a placeholder layout object of the third application component, wherein the layout file of the third application component includes the first user interface component set, and the placeholder layout object of the third application component is used to store the second user interface component set; Establish a binding relationship between the first object and the third application component.
3. The method according to claim 1, wherein After destroying the first application component and the first user interface component set, the method further includes: In response to a third operation instruction, creating a third application component, the third application component being used to provide the first page and implement interactive operations of the first page, the third operation instruction being used to instruct to restore the first page; Creating a user interface component set for the first page based on the third application component, the user interface component set including the first user interface component set and the second user interface component set; Creating a layout file and a placeholder layout object of the third application component, wherein the layout file of the third application component includes the first user interface component set, and the placeholder layout object of the third application component is used to store the second user interface component set; Establish a binding relationship between the first object and the third application component.
4. The method according to claim 1, characterized in that The creation of the layout file and the placeholder layout object for the first application component includes: Creating the layout file and the placeholder layout object for the first application component, where the layout file includes a first set of user interface components and the occupancy layout object, and the placeholder layout object is used to store a second set of user interface components; Or, Creating the layout file and the placeholder layout object for the first application component, where the layout file includes a first set of user interface components, the placeholder layout object is used to store a second set of user interface components, and the placeholder layout object is located in the second application component.
5. The method according to claim 4, characterized in that, When the layout file includes a first set of user interface components and the occupancy layout object, the storing of the second set of user interface components to the second application component in response to the second operation instruction includes: In response to the second operation instruction, removing the second set of user interface components from the placeholder layout object and storing them to the second application component.
6. The method according to claim 4, wherein The creation of the layout file and the placeholder layout object for the first application component includes: Obtaining status information of user interface components corresponding to the first application component, where the status information is used to indicate at least one of update information, power consumption information, and memory occupancy information of the user interface components; Classifying the user interface components into the first set of user interface components or the second set of user interface components according to the status information; Placing the second set of user interface components in the placeholder layout object and placing the first set of user interface components in the layout file.
7. The method according to claim 6, wherein Classifying the user interface components into the first set of user interface components or the second set of user interface components according to the status information includes: When the update information of the user interface component indicates that real-time update is not required, classifying the user interface component into the first set of user interface components; When the update information of the user interface component indicates that real-time update is required, classifying the user interface component into the second set of user interface components.
8. The method according to claim 6, characterized in that, Classifying the user interface components into the first set of user interface components or the second set of user interface components according to the status information includes: When the power consumption information of the user interface component indicates that the power consumption of the user interface component is greater than a first threshold and the memory occupancy, classifying the user interface component into the first set of user interface components; When the power consumption information of the user interface component indicates that the power consumption of the user interface component is less than or equal to the first threshold, classifying the user interface component into the second set of user interface components.
9. The method according to claim 6, characterized in that, Classifying the user interface components into the first set of user interface components or the second set of user interface components according to the status information includes: When the memory occupancy information of the user interface component indicates that the memory occupancy of the user interface component is greater than a second threshold and the memory occupancy, classifying the user interface component into the first set of user interface components; When the memory occupation information of the user interface component indicates that the memory occupation amount of the user interface component is less than or equal to a second threshold, the user interface component is classified into the second user interface component set.
10. The method according to any one of claims 1 to 9, characterized in that After destroying the first application component and the first user interface component set, the method further includes: In response to a fourth operation instruction, a second window is displayed, wherein the second window displays more user interface components than the first window, and the fourth operation instruction is used to instruct to expand the area of the first window.
11. The method according to any one of claims 1 to 9, characterized in that, Before storing the second user interface component set in the second application component in response to the second operation instruction, the method further includes: In response to a fifth operation instruction, releasing the binding relationship between the first object and the first application component, the fifth operation instruction being used to instruct termination of the functional program called by the first page; The first application component, the first user interface component set, and the second user interface component set are destroyed.
12. The method according to any one of claims 1 to 9, characterized in that The function program called by the first page is a voice call function program or a video call function program; The first page includes a user interface component that is updated in real time, and the user interface component that is updated in real time includes a user interface for initiating or hanging up a function program, a user interface for turning on or off the other party's function, and a user interface for turning on or off one's own function.
13. A device for managing the page life cycle, characterized in that include: a creation module, configured to create a first application component of a first page in response to a first operation instruction, wherein the first application component is configured to provide the first page and implement interactive operations on the first page, and the first operation instruction is configured to instruct the creation of the first page; Creating a layout file of the first application component, the layout file comprising a placeholder layout object and a first user interface component set, the placeholder layout object being used to store a second user interface component set, wherein each user interface component in the first user interface component set is a user interface component that is destroyed when the first page is minimized to a first window, and each user interface component in the second user interface component set is a user interface component that is not destroyed when the first page is minimized to a first window; Creating a first object based on the first application component, where the first object is used to indicate a function program called by the first page; A binding module, used to establish a binding relationship between the first object and the first application component, and set the first object as a lifecycle observer of the application component; a processing module, configured to store the second user interface component set from the placeholder layout object to a second application component in response to a second operation instruction, wherein the life cycle of the second application component is longer than the life cycle of the first application component, and the second operation instruction is used to instruct to minimize the first page to the first window; An unbinding module, used to unbind the binding relationship between the first object and the first application component; A destruction module is used to destroy the first application component and the first user interface component set.
14. A computer device, characterized in that, include: Memory, processor, and bus system; Wherein, the memory is used to store programs; The processor is configured to execute the program in the memory, and the processor is configured to execute the method according to any one of claims 1 to 12 based on the instructions in the program code; The bus system is configured to connect the memory and the processor to enable communication between the memory and the processor.
15. A computer-readable storage medium comprising instructions that, when run on a computer, cause the computer to execute the method according to any one of claims 1 to 12.