Data processing method, device, electronic device and storage medium

By annotating and marking page data during the encoding stage of the application, and generating processing files during the compilation stage, and automatically calling processing files for data storage and recovery during the run stage, the loss of page data during the destruction and reconstruction is solved, and the complete recovery of data and the improvement of development efficiency is achieved.

CN114064050BActive Publication Date: 2025-05-23BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111371818.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2025-05-23
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

In the prior art, when the mobile application page is destroyed or rebuilt, the page data cannot be effectively saved or restored, which may lead to data loss and cannot be fully restored to the state before the destruction. At the same time, a large amount of code is required to be written manually, which is time-consuming and labor-intensive and difficult to maintain.

Method used

During the encoding stage of the application, the page data is marked by adding annotations, and the processing files are generated for storage and recovery in the compilation stage. During the running stage, the processing files are automatically called for data storage and recovery.

Benefits of technology

Effectively prevent data loss during page destruction, and fully restore data during page reconstruction, ensuring the normal function of the application page, improving user experience, and reducing the burden of manual coding, improving development efficiency and code maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064050B_ABST
    Figure CN114064050B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data processing method, device, electronic device and storage medium. The method is applied to an electronic device in which an application is running. The method comprises: in a coding stage of the application, marking page data related to an application page of the application by adding annotations; in a compiling stage of the application, generating a processing file for storing and / or restoring the page data based on the marked page data; in a running stage of the application, in response to the destruction of a target page in the application page, calling the corresponding processing file to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, calling the corresponding processing file to restore the target page data stored when the target page is destroyed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art

[0002] Due to the limited memory of mobile phones, when the memory of mobile phones is tight, the pages that users cannot see temporarily in the application running in the mobile phone will be destroyed. When the user returns to the destroyed page, the system will automatically recreate the page and display it. However, if the data in the page is not saved before the page is destroyed, the data may be lost after the system recreates the page, resulting in the page function not being fully displayed. Although the prior art saves the data of the page when the page is destroyed, and restores the saved data when the page is rebuilt, it requires developers to manually write the code corresponding to the data of each page, which is time-consuming and labor-intensive, and the written code is repetitive, mechanical, scattered, and difficult to maintain; at the same time, the code for saving or restoring data is manually written. Since the codes for saving and restoring are not necessarily corresponding, the data of some pages may be lost when the page is rebuilt, and it is impossible to fully restore to the page before destruction. Summary of the invention

[0003] The disclosed embodiments provide a data processing method and device, which can solve the technical problems in the prior art that, when a page is destroyed or rebuilt, page data cannot be effectively saved or restored, and page data may be lost and cannot be restored to the state before the page is destroyed; and the preservation and recovery of page data requires manual writing of a large amount of code, which is time-consuming and labor-intensive, and the written code is not easy to maintain.

[0004] According to one of the solutions of the present disclosure, there is provided a data processing method, which is applied to an electronic device, wherein an application program is running in the electronic device, and the method comprises:

[0005] During the coding phase of the application, marking page data related to the application page of the application by adding annotations;

[0006] In the compiling stage of the application, generating a processing file for storing and / or restoring the page data based on the marked page data;

[0007] During the running stage of the application, in response to the destruction of the target page in the application page, the corresponding processing file is called to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, the corresponding processing file is called to restore the target page data stored when the target page was destroyed.

[0008] In some embodiments, during the compiling phase of the application, generating a processing file for storing and / or restoring the page data based on the marked page data includes:

[0009] Parsing the annotation using a preset annotation processor to obtain page data related to the application page;

[0010] Generate the source code of the processing file using a preset code generation tool according to the page data;

[0011] The source code is compiled to obtain a bytecode file of the processing file.

[0012] In some embodiments, the method further comprises:

[0013] During the compiling phase of the application, adding the bytecode file to a preset location;

[0014] The preset position includes a first position for triggering the destruction of the target page and a second position for triggering the reconstruction of the target page.

[0015] In some embodiments, the processing file includes a first processing file for storing the page data, and in the running stage of the application, in response to the destruction of the target page in the application page, calling the corresponding processing file to store the target page data corresponding to the target page includes:

[0016] After receiving the destruction instruction of the target page, calling and executing the onSaveIntanceState method of the application;

[0017] During the execution of the onSaveIntanceState method, the first processing file is called to store the target page data.

[0018] In some embodiments, the processing file further includes a second processing file for recovering the page data. During the running phase of the application, in response to the reconstruction of the target page in the application page, calling the corresponding processing file to recover the target page data stored when the target page is destroyed includes:

[0019] After receiving the rebuild instruction of the target page, calling and executing the onCreate method of the application;

[0020] During the execution of the onCreate method, the second processing file is called to restore the target page data stored in the first processing file.

[0021] In some embodiments, the method further comprises:

[0022] The target page data stored using the processing file is stored in a database of the electronic device.

[0023] In some embodiments, the method further comprises:

[0024] During the running phase of the application, real-time detection of the available memory size of the electronic device or the memory occupancy rate of the application;

[0025] When the available memory size of the electronic device is less than a first preset threshold or the memory occupancy rate of the application is greater than a second preset threshold, determining the target page to be destroyed;

[0026] The target page data is determined based on the determined target page and the annotation.

[0027] According to one of the solutions of the present disclosure, there is also provided a data processing device, including:

[0028] a marking module configured to mark page data related to an application page of the application by adding annotations during the coding phase of the application;

[0029] A generating module configured to generate, during the compiling phase of the application, a processing file for storing and / or restoring the page data based on the marked page data;

[0030] The processing module is configured to, during the running stage of the application, in response to the destruction of the target page in the application page, call the corresponding processing file to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, call the corresponding processing file to restore the target page data stored when the target page is destroyed.

[0031] According to one of the solutions of the present disclosure, there is also provided an electronic device, including: a processor and a memory; the memory stores computer-executable instructions; and the processor implements the above method when executing the computer-executable instructions stored in the memory.

[0032] According to one of the solutions of the present disclosure, there is also provided a computer-readable storage medium on which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the above method is implemented.

[0033] The data processing methods, devices, electronic devices and storage media provided by various embodiments of the present disclosure mark the page data related to the application page in advance by injecting annotations during the coding stage of the application, and automatically generate a processing file for storing and / or restoring the page data according to the marked page data during the compilation stage of the application, and then automatically identify the page data corresponding to the application page to be stored or restored in response to the operation on the application page during the running stage of the application, and call the corresponding processing file generated in the compilation stage to store and / or restore the page data, which can effectively prevent the loss of page data when the page is destroyed and can completely restore the page data when the page is rebuilt, ensuring that the page function of the application is normal and improving the user experience. In addition, a processing file for storing and / or restoring page data can be automatically generated, without the need for developers to manually write program code for storing and / or restoring data for each application page, which can effectively improve data processing efficiency, improve application development efficiency, and the generated code is easy to maintain. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram showing an implementation environment of an embodiment of the present disclosure;

[0035] Figure 2 A flowchart showing a data processing method according to an embodiment of the present disclosure;

[0036] Figure 3 Another flow chart showing the data processing method according to an embodiment of the present disclosure;

[0037] Figure 4 Another flow chart showing the data processing method according to the embodiment of the present disclosure;

[0038] Figure 5 Another flow chart showing the data processing method according to the embodiment of the present disclosure;

[0039] Figure 6 A schematic diagram showing the structure of a data processing device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0040] Various aspects and features of the present disclosure are described herein with reference to the drawings.

[0041] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present disclosure will occur to those skilled in the art.

[0042] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the general description of the present disclosure given above and the detailed description of the embodiments given below, serve to explain the principles of the present disclosure.

[0043] These and other characteristics of the present disclosure will become apparent from the following description of a preferred form of embodiment given as a non-limiting example, with reference to the attached drawings.

[0044] It should also be understood that although the disclosure has been described with reference to certain specific examples, those skilled in the art will be able to readily implement many other equivalent forms of the disclosure.

[0045] The above and other aspects, features and advantages of the present disclosure will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.

[0046] Specific embodiments of the present disclosure are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments claimed are merely examples of the present disclosure, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid obscuring the present disclosure with unnecessary or redundant details. Therefore, the specific structural and functional details claimed herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present disclosure in a variety of ways with substantially any suitable detailed structure.

[0047] In view of the above technical problems, an embodiment of the present disclosure provides a data processing method.

[0048] Figure 1 A schematic diagram of an implementation environment involved in the embodiment of the present disclosure is shown. The implementation environment may include: a development terminal 10 and a user terminal 20.

[0049] The development terminal 10 refers to the terminal used by the developer. The developer writes the program source code through the development terminal 10, and then compiles the program source code into an executable file (bytecode file) that can run on hardware through a java source code compiler, and then packages the executable file to generate an installation package (APK) of the application. The program source code can be a java code and a resource file such as xml. The above-mentioned java code and resource files such as xml are converted into bytecode files, and then converted into .apk files, so as to realize the compilation of the application. After the development terminal 10 synchronously compiles the source code and other resource files into an installation package (APK), it can be sent to the user terminal 20 for the user to download and use.

[0050] The user terminal 20 refers to a terminal used by a user. The user terminal 20 and the development terminal 10 are connected via a network 30. The user terminal 20 may be installed with an application developed by the development terminal 10. For example, after receiving the installation package sent by the development terminal 10, the user may install and run the application. That is, the running of the application refers to the process of loading the executable file into the user terminal 20. The application running on the user terminal 20 may interact with the user and has a visual user interface (page), and each page contains corresponding page data.

[0051] In the disclosed embodiment, the application program may be a shopping application program, an information application program, a game application program, an audio application program, a video playback application program, and the like. The development terminal 10 may be an electronic device with computing capabilities, such as a desktop computer, a laptop computer, a tablet computer, etc. The user terminal 20 may be a fixed terminal device, such as a server, a desktop computer, a digital TV, etc., or a mobile terminal device, such as a handheld device (such as a mobile phone, a tablet computer, etc.), a vehicle-mounted device, a wearable device (such as a smart watch, a smart bracelet, a pedometer, etc.).

[0052] In a specific implementation, the development terminal 10 and the user terminal 20 may also be the same electronic device, that is, the electronic device can not only develop (encode and compile) the application program, but also run the application program.

[0053] Optionally, the implementation environment may also include a server 40, which may store various program files generated by developers during the process of developing applications; program files required to be called when the application is running on the user terminal 20 may be obtained from the server 40, that is, the server 40 may be connected to the development terminal 10 and the user terminal 20 through a wired or wireless network, respectively, to achieve data interaction between the development terminal 10 and the user terminal 20. The server 40 may be an independent server, or a server cluster consisting of multiple servers, or a cloud computing service center. In other embodiments, the server 40 may also perform the compilation of the application, that is, the coding process of the application is performed on the development terminal 10, the compilation process is performed on the server 40, and the running process is performed on the user terminal 20.

[0054] The data processing method provided by the present disclosure can be implemented in a collaborative manner through the above-mentioned development terminal 10 and the user terminal 20, or can be implemented in a collaborative manner through the above-mentioned development terminal 10, the user terminal 20 and the server 40, or can be implemented independently through the above-mentioned development terminal 10 or the user terminal 20. For the convenience of description, the following description will take electronic devices as examples.

[0055] Electronic devices have different operating systems to provide corresponding operating environments for different applications. For example, the mobile phone operating system may be an Android system or an iOS system, and the operating system of a desktop computer may be a Windows operating system. In this embodiment, the electronic device may be an electronic device based on the Android system.

[0056] Figure 2 FIG. 1 is a flow chart showing a data processing method according to an embodiment of the present disclosure. Figure 2 As shown, an embodiment of the present disclosure provides a data processing method, which is applied to an electronic device, wherein an application program is running in the electronic device, and the method includes:

[0057] S101: During the coding stage of the application, page data related to the application page of the application is marked by adding annotations.

[0058] The application can be a third-party application installed on the electronic device. For a certain application, the developer can use custom annotations to mark the page data that needs to be saved in each application page during the coding of the application (writing the program code for each page implementation), and generate the source code of the application based on the application page information and the marked page data, and write the source code into the source code file of the application for storage.

[0059] The annotation code starts with @. In this embodiment, the annotation @KeepData can be used to mark and save the page data so that users can easily find the page data, and the annotation method will not affect the logic of the source code of the page data. In the disclosed embodiment, the page data corresponding to each application page carries a corresponding annotation to mark the page data.

[0060] The code stored in the source code file can be java code and resource files such as xml. In this embodiment, the source code file not only contains the annotation code corresponding to the annotation of the above page data, but also contains other program codes for running the application. Other program codes refer to the prior art and are not repeated here.

[0061] S102: During the compiling phase of the application, a processing file for storing and / or restoring the page data is generated based on the marked page data.

[0062] Application compilation refers to the process of compiling the source code files of the application into bytecode files that can be run on electronic devices through a compiler, and packaging the bytecode files to generate .apk files.

[0063] During the compilation phase of the application, the source code file obtained by encoding can be searched, and the data marked by the annotation @KeepData can be searched from the source code file to find the page data corresponding to the application page. After the page data is found, a processing file for storing and / or restoring the page data can be automatically generated. The generated processing file can be a java source code file for processing the page data.

[0064] S103: During the running phase of the application, in response to the destruction of the target page in the application page, the corresponding processing file is called to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, the corresponding processing file is called to restore the target page data stored when the target page is destroyed.

[0065] The target page refers to the page to be destroyed or rebuilt in the application page. The target page may refer to a page running in the background and temporarily unavailable to the user. The target page corresponding to the target page may be page element data such as text, images, controls, etc. displayed on the target page, or may be control data for realizing the above-mentioned image display function, control function, etc., that is, the target page data is page data that can generate the above-mentioned target page.

[0066] After determining the processing operation for the target page, for example, destroying the target page or restoring the destroyed target page, the electronic device can automatically call the compilation phase to generate a corresponding processing file to process the target page data corresponding to the target page.

[0067] For example, when it is determined to destroy the target page, the processing file is called to store the corresponding target page data, which can prevent the loss of page data and facilitate the subsequent reconstruction of the target page; when it is determined to rebuild the target page, the processing file is called to restore all the corresponding target page data to ensure the integrity of the target page reconstruction, and the reconstructed target page and corresponding functions will not be missing or the page cannot be rebuilt due to the loss of some page data, affecting the user experience.

[0068] The data processing method provided by the embodiment of the present disclosure marks the page data related to the application page in advance by injecting annotations during the coding stage of the application, and automatically generates a processing file for storing and / or restoring the page data according to the marked page data during the compilation stage of the application, and then automatically identifies the page data corresponding to the application page to be stored or restored in response to the operation on the application page during the running stage of the application, and calls the corresponding processing file generated in the compilation stage to store and / or restore the page data, which can effectively prevent the loss of page data when the page is destroyed and can completely restore the page data when the page is rebuilt, thereby ensuring that the page function of the application performs normally and improving the user experience.

[0069] In addition, in this embodiment, a processing file for storing and / or restoring page data can be automatically generated, without the need for developers to manually write program code for storing and / or restoring data for each application page, which can effectively improve data processing efficiency, improve application development efficiency, and the generated code is easy to maintain. Specifically, a code template can be set, and the code template can be used to generate the corresponding processing file code, reducing repeated code writing, and some codes can be reused; at the same time, the processing files generated based on the same code template can be centrally managed to reduce code dispersion and facilitate code maintenance; in addition, a small amount of code can be manually written when generating a processing file, so that the generated processing file is rich and diverse, and can be applied to different page data.

[0070] In some embodiments, Figure 3 As shown, in step S102, during the compiling stage of the application, a processing file for storing and / or restoring the page data is generated based on the marked page data, including:

[0071] S1021: parsing the annotation using a preset annotation processor to obtain page data related to the application page;

[0072] S1022: Generate the source code of the processing file using a preset code generation tool according to the page data;

[0073] S1023: Compile the source code to obtain a bytecode file of the processing file.

[0074] The preset annotation processor may be APT (Annotation Process Tool) of Java, and the annotation processor may parse the above-mentioned custom annotation @KeepData, read the data in the detected annotation, and thereby obtain the page data related to the application page.

[0075] After the electronic device obtains the relevant information of the annotation and the annotated object (page data) through APT during the compilation stage of the application, it can use the javapoet tool, a code generation tool, to automatically generate the source code of the processing file for storing and / or restoring the above page data, eliminating the need to manually write a large amount of code and improving coding efficiency.

[0076] Furthermore, the source code of the generated processing file can be saved in the source file of the application so that the processing file can be used in the overall compilation process of the application. For example, the processing file can be encapsulated to generate a java source file named KeepDataHelp.java, which stores the corresponding page data processing program code. By calling the compiled KeepDataHelp.java, the above processing program code can be executed to process the page data.

[0077] Among them, the source file (such as a java source file) is the source code file library of the application, and the program source code of the application is stored in the source file. After the program source code is compiled, a bytecode file (executable file) that can be run on an electronic device is generated. After the bytecode file is called and executed, the corresponding application and each application page in the application can be run. For example, after writing the source code that conforms to the java syntax in the ".java" file, it can be compiled. After the java source code is compiled, one or more ".class" files will be generated. The ".class" file is a bytecode file, which is an executable file that enables the application to run. After the java program is compiled into a class file, it is also necessary to use the dex tool to integrate all the class files into a dex file so that the various classes therein can share data, which reduces class redundancy to a certain extent.

[0078] In this embodiment, the use of a preset annotation processor to obtain annotations and the use of a preset code generation tool to generate source code for processing files are both performed during the compilation process of the application. Compared with using a reflection mechanism to process annotations during application runtime, the program performance is greatly improved and efficiency problems caused by using reflection at runtime are avoided. At the same time, the generated source code is compiled into a bytecode file that can be run directly on an electronic device, that is, the bytecode can be run directly during the operation of the application, which not only solves the problem of low encoding efficiency, but also avoids the problem of reduced operating efficiency caused by parsing annotations during runtime.

[0079] In some embodiments, the method further comprises:

[0080] S201: During the compilation phase of the application, the bytecode file is added to a preset location;

[0081] The preset position includes a first position for triggering the destruction of the target page and a second position for triggering the reconstruction of the target page.

[0082] After obtaining the bytecode file corresponding to the processing file through S1021 to S1023, the bytecode file is added to the original bytecode file of the application, thereby realizing the overall compilation of the application. In this embodiment, after determining the target page to be destroyed or restored, the bytecode file can be added to the position (first position) of the destruction bytecode file used to trigger the destruction of the target page, and the bytecode file can also be added to the position (second position) of the reconstruction bytecode file used to trigger the reconstruction of the target page, so that when destroying or rebuilding the target page, the corresponding processing file is called in time (by determining the target page to be destroyed or restored, the position of the corresponding processing file can be determined), and the target page data corresponding to the target page is stored and / or restored.

[0083] Specifically, the developer of the application can write a Gradle plug-in, insert the Gradle plug-in into the compilation process, and in the Transform stage of the gradle compilation (that is, the java to dex stage), compile the java source file through the TransformAPI provided by the Gradle plug-in, find the bytecode plug-in entry (the first position and the second position in this embodiment), and insert the bytecode file corresponding to the processing file (the above-mentioned KeepDataHelp.java file) into the above-mentioned preset position; then use the ASM bytecode tool to modify the bytecode (instructions) of the java source file, add the bytecode file corresponding to the processing file to the original java source file of the application, and the modified java bytecode is converted into an apk file via the dex file. That is, in this embodiment, the above-mentioned KeepDataHelp.java file can be inserted into the preset position of the position through the Gradle plug-in.

[0084] Gradle Transform is a set of standard APIs officially provided by Android to developers to modify .java files during the project build phase (.java->.dex conversion), that is, to convert the input .java files into target bytecode files, thereby achieving bytecode instrumentation, code injection, etc.

[0085] In this embodiment, during the compiling stage of the application, the processing files required to implement the data processing method are injected into the code of the application (generating the source code of the processing file, compiling the source code into a bytecode file, and inserting the bytecode file into the corresponding preset position). Since the injection of the processing file is completed during the compiling stage of the application, only the corresponding processing file needs to be called and loaded during the running stage, so that the performance of the application running in the electronic device will not be affected. In addition, since the ASM bytecode tool mainly focuses on the ease of operation, it is more compact and fast, and is particularly suitable for the dynamically changing target page and target page data in this embodiment.

[0086] In some embodiments, the processing file includes a first processing file for storing the page data, such as Figure 4 As shown, in step S103, during the running stage of the application, in response to the destruction of the target page in the application page, calling the corresponding processing file to store the target page data corresponding to the target page includes:

[0087] S1031: after receiving the destruction instruction of the target page, calling and executing the onSaveIntanceState method of the application;

[0088] S1032: During the execution of the onSaveIntanceState method, the first processing file is called to store the target page data.

[0089] The Android system provides corresponding APIs that allow developers to save the data they want to save when the page is destroyed, and allow developers to restore the data when the page is rebuilt by the system. onSaveIntanceState is an opportunity provided by the Android system to store data, giving users the opportunity to store some non-permanent data.

[0090] In this embodiment, by using the onSaveIntanceState provided by the system, the electronic device can call the first processing file to store the target page data during the execution of the onSaveIntanceState method, that is, the Android system's own timing for storing data can be used, and there is no need to set an additional timing for data storage, and the first processing file can be automatically called, thereby realizing rapid data storage. The first processing file is a compiled program code for storing target page data. The target page data to be stored can be stored by directly calling the first processing file, without the developer having to pass the data to be stored to the outState parameter, which can reduce the amount of data transmission and improve the storage response rate.

[0091] In some embodiments, the processing file further includes a second processing file for recovering the page data, such as Figure 5 As shown, in step S103, in the running stage of the application, in response to the reconstruction of the target page in the application page, calling the corresponding processing file to restore the target page data stored when the target page is destroyed includes:

[0092] S1033: after receiving the target page reconstruction instruction, calling and executing the onCreate method of the application;

[0093] S1034: During the execution of the onCreate method, the second processing file is called to restore the target page data stored in the first processing file.

[0094] Similar to the above-mentioned onSaveIntanceState, onCreate is a time provided by the Android system for data recovery. The electronic device can call the second processing file to automatically recover the target page data during the execution of the onCreate method, without setting an additional recovery time, and without returning the target page data stored in the first processing file through the savedInstanceState parameter for recovery, which can also reduce the amount of data transmission and improve the storage response rate.

[0095] In a specific implementation, the first processing file and the second processing file can be different source files respectively, so as to be applicable to different processing operations; the first processing file and the second processing file can also be different files stored in the same source file, that is, the same source file can store both program codes for storing data and program codes for recovering data, so as to facilitate the electronic device to call and execute.

[0096] It is understandable that in step S1034, when performing data recovery, the target page data recovered can be the target page data saved by using the first processing file in steps S1031 and S1032. The target page data is the complete page data corresponding to the target page before it is destroyed. Therefore, when the destroyed target page is rebuilt, the second processing file is called to restore the target page data stored in the first processing file, so that the page data before the target page is destroyed is completely consistent with the page data after reconstruction, thereby achieving complete recovery of the page data and avoiding affecting the user experience.

[0097] In some other embodiments, the target page data to be restored may be page data stored in other ways before the page is destroyed, and the specific storage method is not specifically limited in this disclosure.

[0098] In some embodiments, the method further comprises:

[0099] S301: Storing the target page data stored using the processing file in a database of the electronic device.

[0100] Since onSaveIntanceState and onCreate use the Bundle parameter provided by the Android system to store and restore data, the Bundle mechanism is a "container" for transferring data, and the data it saves exists in the form of key-value pairs. Therefore, the data types supported by the Bundle provided by the system for storing and restoring data are limited. Bundle only supports basic data types and types that implement the Serializable interface, and does not support the storage and restoration of other common objects, pictures and other binary object types.

[0101] In this embodiment, the target page data stored by the processing file is stored in a database of the electronic device. Since the database supports the storage of any type of data such as basic data types and binary types (such as pictures), the problem of limited data types stored in the Bundle in the prior art can be solved. The database can be a local database or a cloud database.

[0102] Optionally, for common object data, the data content of the object can be converted into a JSON string type and then stored in the database.

[0103] In this embodiment, the data types of the target page data to be stored or restored include basic data types (such as int, float, boolean, byte, double, char, long, short), String type, Class type, enum type, Annotation type and arrays of all the above types.

[0104] In addition, since this embodiment does not use Bundle to store and restore data, but uses a database to store and restore data, and since the database can be shared among different pages, different page data stored in different pages in the database can support cross-page sharing, thereby improving the compatibility of page data. That is, the same page data in different pages can be stored only once and shared, which can effectively reduce the memory usage of the electronic device.

[0105] In some embodiments, the method further comprises:

[0106] S401: During the running phase of the application, detecting in real time the available memory size of the electronic device or the memory occupancy rate of the application;

[0107] S402: When the available memory size of the electronic device is less than a first preset threshold or the memory occupancy rate of the application is greater than a second preset threshold, determining the target page to be destroyed;

[0108] S403: Determine the target page data based on the determined target page and the annotation.

[0109] The memory of electronic devices such as mobile phones generally includes system memory and running memory, wherein the system memory is the running space of the Android system or iOS system, and the running memory is the running space of the application. In this embodiment, the available memory of the electronic device generally refers to the running space of the application, and the data of the application stored therein may be non-permanent data so that the user can clean it up in time. The electronic device can monitor the memory occupancy in real time during the running of the application.

[0110] When the application is running, multiple pages may be running, and the pages can run in the foreground or the background. When the page runs in the foreground, it will generally be displayed on the display interface of the electronic device, such as the screen of a mobile phone. As the application runs, there may be more and more pages running, and more and more data in the memory. The memory occupancy rate of the application gradually increases, and the available memory of the electronic device gradually decreases. When the available memory of the electronic device is lower than the first preset threshold or the memory occupancy rate of the application is greater than the second preset threshold, the currently displayed page may load slowly or cannot be displayed normally, and may even cause the application to crash and cannot run normally. Therefore, in order to ensure the normal operation of the application, when it is detected that the available memory of the electronic device is lower than the first preset threshold or the memory occupancy rate of the application is greater than the second preset threshold, the page that the user cannot see temporarily in the application can be destroyed to release the memory space, and the page can be rebuilt when the user needs to view the page.

[0111] Through steps S401 and S402, when the available memory of the electronic device is low or the memory occupancy rate of the application in the electronic device is too large, the target page to be destroyed is automatically identified; after the target page is determined through step S402, the page data corresponding to the target page can be annotated during the application coding phase to find out the target page data corresponding to the target page, and then the target page data can be stored and / or restored, which can avoid the loss of page data when the page is rebuilt and ensure the reliable operation of the application.

[0112] In a specific implementation, pages that are temporarily invisible to the user can also be destroyed based on the running time of the application in the electronic device. For example, when the application runs for a long time, the invisible pages can be destroyed at the first time, and the page data corresponding to the page can be stored using the first processing file; after a certain period of time, when the destroyed page needs to be displayed at a second time, the page can be rebuilt at the second time, and the page data stored at the time of destruction can be restored using the second processing file.

[0113] In some embodiments, in step S402, determining the target page to be destroyed includes:

[0114] S4021: Determine, based on the currently displayed first application page, a second application page that has been displayed when the application is running;

[0115] S4022: Determine the second application page as the target page.

[0116] Specifically, when the application is running, the electronic device can monitor the currently displayed application page in real time. When determining that the first application page is currently displayed, the second application page displayed earlier than the first display time can be screened out based on the first display time of the current first application page, and it can be determined as the displayed application page. The displayed application page and the corresponding page data are stored in the memory of the electronic device. The displayed page (second application page) can be determined as the target page, and one or some pages of the displayed second application page can also be determined as the target page, so as to destroy it or rebuild it after destruction.

[0117] In some other embodiments, in step S402, determining the target page to be destroyed includes:

[0118] S4023: Determine a third application page currently running in the background according to the first application page currently displayed;

[0119] S4024: Determine the third application page as the target page.

[0120] Specifically, after determining the currently displayed first application page (running in the foreground), the third application page currently running in the background can be determined. Since the third application page is not displayed, the third application page can be destroyed as the target page and rebuilt and displayed when the third application page needs to run in the foreground.

[0121] In some embodiments, in step S103, in response to destroying the target page in the application page, after calling the corresponding processing file to store the target page data corresponding to the target page, the method further includes:

[0122] S1041: Destroy the target page.

[0123] In step S103, in response to the reconstruction of the target page in the application page, after calling the corresponding processing file to restore the target page data stored when the target page is destroyed, the method further includes:

[0124] S1042: Load the restored target page data into the reconstructed target page.

[0125] Specifically, the target page can be rebuilt using the restored target page data, so that the target page is restored to the state before being destroyed, thereby ensuring the smooth operation of the application program.

[0126] Figure 6 FIG. 2 shows a schematic diagram of the structure of a data processing device according to an embodiment of the present disclosure. Figure 6 As shown, the embodiment of the present disclosure also provides a data processing device, including:

[0127] The marking module 601 is configured to mark the page data related to the application page of the application by adding annotations during the coding stage of the application;

[0128] A generating module 602, configured to generate a processing file for storing and / or restoring the page data based on the marked page data during the compiling phase of the application;

[0129] The processing module 603 is configured to, during the running stage of the application, in response to the destruction of the target page in the application page, call the corresponding processing file to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, call the corresponding processing file to restore the target page data stored when the target page was destroyed.

[0130] In some embodiments, the generation module 602 is specifically configured as follows:

[0131] Parsing the annotation using a preset annotation processor to obtain page data related to the application page;

[0132] Generate the source code of the processing file using a preset code generation tool according to the page data;

[0133] The source code is compiled to obtain a bytecode file of the processing file.

[0134] In some embodiments, the generation module 602 is further configured to:

[0135] During the compiling phase of the application, adding the bytecode file to a preset location;

[0136] The preset position includes a first position for triggering the destruction of the target page and a second position for triggering the reconstruction of the target page.

[0137] In some embodiments, the processing file includes a first processing file for storing the page data, and the processing module 603 is specifically configured as follows:

[0138] After receiving the destruction instruction of the target page, calling and executing the onSaveIntanceState method of the application;

[0139] During the execution of the onSaveIntanceState method, the first processing file is called to store the target page data.

[0140] In some embodiments, the processing file further includes a second processing file for recovering the page data, and the processing module 603 is specifically configured as follows:

[0141] After receiving the rebuild instruction of the target page, calling and executing the onCreate method of the application;

[0142] During the execution of the onCreate method, the second processing file is called to restore the target page data stored in the first processing file.

[0143] In some embodiments, the data processing apparatus further comprises:

[0144] The storage module is configured to store the target page data stored using the processing file in a database of the electronic device.

[0145] In some embodiments, the data processing apparatus further comprises:

[0146] A detection module, configured to detect the available memory size of the electronic device or the memory occupancy rate of the application in real time during the running stage of the application;

[0147] A first determining module is configured to determine the target page to be destroyed when the available memory size of the electronic device is less than a first preset threshold or the memory occupancy rate of the application is greater than a second preset threshold;

[0148] The second determination module is configured to determine the target page data based on the determined target page and the annotation.

[0149] The data processing device provided in the embodiments of the present disclosure corresponds to the data processing method in the above-mentioned embodiments. Based on the above-mentioned data processing method, technicians in this field can understand the specific implementation methods of the data processing device in the embodiments of the present disclosure and its various variations. Any optional items in the data processing method embodiments are also applicable to the data processing device and will not be repeated here.

[0150] The embodiment of the present disclosure also provides an electronic device, including: a processor and a memory; the memory stores computer-executable instructions; when the processor executes the computer-executable instructions stored in the memory, the above-mentioned data processing method is implemented.

[0151] The electronic devices of the embodiments of the present disclosure may include but are not limited to fixed terminal devices such as servers, desktop computers, digital TVs, etc., and mobile terminal devices such as handheld devices (such as mobile phones, tablet computers, etc.), vehicle-mounted devices, wearable devices (such as smart watches, smart bracelets, pedometers, etc.), etc.

[0152] The embodiment of the present disclosure further provides a computer-readable storage medium on which computer execution instructions are stored. When the computer execution instructions are executed by a processor, the above-mentioned data processing method is implemented.

[0153] The computer-readable storage medium of the embodiment of the present disclosure may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiment of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it.

[0154] In the disclosed embodiment, the computer executable instruction program code for performing the disclosed operation can be written in one or more programming languages ​​or a combination thereof, and the programming languages ​​include Java, C++, PHP, Python, etc. The program code can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on the remote computer, or completely on the remote computer or terminal. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0155] The above embodiments are only exemplary embodiments of the present disclosure and are not intended to limit the present disclosure. The protection scope of the present disclosure is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present disclosure within the essence and protection scope of the present disclosure, and such modifications or equivalent substitutions shall also be deemed to fall within the protection scope of the present disclosure.

Claims

1. A data processing method, applied to an electronic device, wherein an application program is running in the electronic device, and the method include: During the coding phase of the application, marking page data related to the application page of the application by adding annotations; In the compiling stage of the application, generating a processing file for storing and / or restoring the page data based on the marked page data; In the running stage of the application, in response to the destruction of the target page in the application page, the corresponding processing file is called to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, the corresponding processing file is called to restore the target page data stored when the target page is destroyed; Wherein, in the compiling stage of the application, generating a processing file for storing and / or restoring the page data based on the marked page data includes: Parsing the annotation using a preset annotation processor to obtain page data related to the application page; Generate the source code of the processing file using a preset code generation tool according to the page data; The source code is compiled to obtain a bytecode file of the processing file.

2. The method according to claim 1, in, The method further comprises: During the compiling phase of the application, adding the bytecode file to a preset location; The preset position includes a first position for triggering the destruction of the target page and a second position for triggering the reconstruction of the target page.

3. The method according to claim 1, in, The processing file includes a first processing file for storing the page data. In the running stage of the application, in response to the destruction of the target page in the application page, calling the corresponding processing file to store the target page data corresponding to the target page includes: After receiving the destruction instruction of the target page, calling and executing the onSaveIntanceState method of the application; During the execution of the onSaveIntanceState method, the first processing file is called to store the target page data.

4. The method according to claim 3, in, The processing file also includes a second processing file for recovering the page data. In the running stage of the application, in response to the reconstruction of the target page in the application page, the corresponding processing file is called to recover the target page data stored when the target page is destroyed, including: After receiving the rebuild instruction of the target page, calling and executing the onCreate method of the application; During the execution of the onCreate method, the second processing file is called to restore the target page data stored in the first processing file.

5. The method according to claim 1, in, The method further comprises: The target page data stored using the processing file is stored in a database of the electronic device.

6. The method according to claim 1, in, The method further comprises: During the running phase of the application, real-time detection of the available memory size of the electronic device or the memory occupancy rate of the application; When the available memory size of the electronic device is less than a first preset threshold or the memory occupancy rate of the application is greater than a second preset threshold, determining the target page to be destroyed; The target page data is determined based on the determined target page and the annotation.

7. A data processing device, include: a marking module configured to mark page data related to an application page of the application by adding annotations during a coding phase of the application; A generating module configured to generate, during the compiling phase of the application, a processing file for storing and / or restoring the page data based on the marked page data; a processing module configured to, during the running phase of the application program, in response to the destruction of the target page in the application page, call the corresponding processing file to store the target page data corresponding to the target page, and / or in response to the reconstruction of the target page in the application page, call the corresponding processing file to restore the target page data stored when the target page is destroyed; The generation module is specifically configured as follows: Parsing the annotation using a preset annotation processor to obtain page data related to the application page; Generate the source code of the processing file using a preset code generation tool according to the page data; The source code is compiled to obtain a bytecode file of the processing file.

8. An electronic device, include: Processor and memory; The memory stores computer-executable instructions; When the processor executes the computer-executable instructions stored in the memory, the method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having computer-executable instructions stored thereon, wherein the computer-executable instructions, when executed by a processor, implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Android application development method and device based on MVPVM, equipment and medium

    CN111596906A

  • Page loading time consumption determination method and device, and computer readable storage medium

    CN111625432A