CN114115862B - Data processing method, device, electronic device and storage medium - Google Patents
Data processing method, device, electronic device and storage mediumInfo
- Publication number
- CN114115862B CN114115862B CN202111427879.4A CN202111427879A CN114115862B CN 114115862 B CN114115862 B CN 114115862B CN 202111427879 A CN202111427879 A CN 202111427879A CN 114115862 B CN114115862 B CN 114115862B
- Authority
- CN
- China
- Prior art keywords
- class
- initialized
- component
- initialization
- code
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/36—Software reuse
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The application discloses a data processing method, a data processing device, electronic equipment and a storage medium. By the method and the device, when the initialized attribute and the attribute for merging to the ContentProvider are required to be set for the class to be initialized in each component in the application program in the development environment of the application program, codes of the initialized attribute for the class to be initialized in each component in the development environment of the application program can not be written, and codes of the attribute for merging to the ContentProvider can not be written for the class to be initialized in each component in the application program. And only one initialization code template and the class name of the class to be initialized in the component can be set in the development environment, so that the code development amount can be reduced, and the labor cost is further reduced.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data processing method, a data processing device, an electronic device, and a storage medium.
Background
In the process that the user uses the application program on the mobile phone, the application program may be switched to background operation of an operating system of the mobile phone, so that the operating system may recycle a thread of the application program, that is, close the thread of the application program to save system resources of the mobile phone, then when the user switches the application program to foreground operation of the operating system again, the operating system starts the thread for the application program to start the application program, and when the application program is started, the class to be initialized in each Library component in the application program is initialized, and a page displayed before the last background operation is displayed.
In order to initialize the class to be initialized in each Library component in the application program when the application program is started, in one way, when the source code of the application program is developed, the code of the class to be initialized in each Library component may be written into onCreate methods in the ContentProvider class.
In this way, after compiling the computer program code to obtain the application program, in the process of starting the application program, in order to initialize the class to be initialized in each Library component in the application program, a ContentProvider class may be created, and the class to be initialized in each Library component is respectively processed by using the ContentProvider class, so that the class to be initialized in each Library component is respectively initialized.
However, since initializing the class to be initialized in each component by using the ContentProvider class is required, it is required not only to write the code of the initialized attribute for the class to be initialized in each component but also to write the code of the attribute to be initialized in each component in the application separately for merging to the ContentProvider class in the development environment of the application. Resulting in a large code development and thus high labor costs.
Disclosure of Invention
The application discloses a data processing method, a data processing device, electronic equipment and a storage medium.
In a first aspect, the present application provides a data processing method, applied to an electronic device, where the electronic device runs a development environment of an application program, the development environment includes at least one content provider ContentProvider class, an auxiliary plug-in, and at least one component of the application program, each component includes at least one class to be initialized, and the method includes:
The method comprises the steps of obtaining an initialization code template set in an auxiliary plug-in, wherein the initialization code template comprises a first code section and a second code section, the first code section at least comprises a class name of a ContentProvider class and a preset merging tag used for indicating merging to the ContentProvider class according to the class name, and the second code section at least comprises a class name adding bit and a preset initialization tag used for indicating that a class corresponding to the class name added on the class name adding bit needs to be initialized;
for any one of the at least one component, obtaining a class name of a class to be initialized in the component from a plug-in file corresponding to the auxiliary plug-in the component;
The method comprises the steps of adding class names of classes to be initialized in a component in a class name adding bit in an initialization code template to obtain an initialization code of the classes to be initialized in the component, wherein the initialization code comprises a first code segment and a second code segment, the first code segment at least comprises the class names of the ContentProvider classes and preset merging labels used for indicating merging of the class names of the ContentProvider classes to the ContentProvider classes according to the class names of the ContentProvider classes, and the second code segment at least comprises the class names of the classes to be initialized and preset initialization labels used for indicating that the classes corresponding to the class names of the classes to be initialized need to be initialized;
storing the initialization code of the class to be initialized in the component in a sub-manifest file of the class to be initialized in the component.
In an alternative implementation, the method further includes:
Creating an auxiliary plug-in the development environment, and setting the initialization code template in the auxiliary plug-in;
And
And for any one of the at least one component, creating a plug-in file corresponding to the auxiliary plug-in the component, and setting a class name of a class to be initialized in the component in the plug-in file.
In an alternative implementation, the method further includes:
In the case of generating an executable file of the application program from source code of the application program that has been developed in the development environment, the auxiliary plug-in is deleted or the initialization code template is deleted in the auxiliary plug-in.
In an alternative implementation, the method further includes:
under the condition that the initialization code template is required to be upgraded, a new version of auxiliary plug-in is obtained, and the new version of initialization code template is arranged in the new version of auxiliary plug-in;
The auxiliary plug-in of the new version is used for replacing the auxiliary plug-in existing in the development environment.
In an alternative implementation, the method further includes:
in the case of generating an executable file of the application program according to source codes of the application program which have been developed in the development environment, searching whether initializing codes with the preset initializing tag exist in sub-manifest files in each class in the source codes respectively;
Acquiring a class name of a class to be initialized recorded in a second code segment in an initialization code of the preset initialization tag, and acquiring a class name of the ContentProvider class recorded in a first code segment in the initialization code of the preset initialization tag and the preset merge tag;
Generating a tag set in the ContentProvider class in the executable file;
and adding the obtained class names of the various classes to be initialized in the tag set according to the class names of the ContentProvider classes and the preset merging tag.
In a second aspect, the present application provides a data processing apparatus, applied to an electronic device, where the electronic device runs a development environment of an application program, the development environment includes at least one content provider ContentProvider class, an auxiliary plug-in, and at least one component of the application program, each component includes at least one class to be initialized, and the apparatus includes:
the system comprises an auxiliary plug-in, a first acquisition module, a second acquisition module and a first storage module, wherein the auxiliary plug-in is used for storing an initialization code template which is set in the auxiliary plug-in, the initialization code template comprises a first code segment and a second code segment, the first code segment at least comprises a class name of the ContentProvider class and a preset merging tag which is used for indicating merging of the class name into the ContentProvider class according to the class name, and the second code segment at least comprises a class name adding bit and a preset initialization tag which is used for indicating that a class corresponding to the class name added on the class name adding bit needs to be initialized;
The second obtaining module is used for obtaining the class name of the class to be initialized in the component in the plug-in file corresponding to the auxiliary plug-in the component for any one of the at least one component;
the system comprises a first adding module, a first initializing module, a second initializing module and a first initializing module, wherein the first adding module is used for adding class names of classes to be initialized in the components in class name adding bits in an initializing code template to obtain initializing codes of the classes to be initialized in the components, the initializing codes comprise a first code section and a second code section, the first code section in the initializing codes at least comprises the class names of the ContentProvider classes and preset merging labels used for indicating merging of the class names of the ContentProvider classes into the ContentProvider classes, and the second code section in the initializing codes at least comprises the class names of the classes to be initialized and the preset initializing labels used for indicating that the classes corresponding to the class names of the classes to be initialized need to be initialized;
And the storage module is used for storing the initialization codes of the classes to be initialized in the component in the sub-manifest files of the classes to be initialized in the component.
In an alternative implementation, the apparatus further includes:
The first setting module is used for creating an auxiliary plug-in the development environment, and setting the initialization code template in the auxiliary plug-in;
And
And the second setting module is used for creating a plug-in file corresponding to the auxiliary plug-in any one of the at least one component, and setting a class name of a class to be initialized in the component in the plug-in file.
In an alternative implementation, the apparatus further includes:
And the deleting module is used for deleting the auxiliary plug-in or deleting the initialization code template in the auxiliary plug-in under the condition that an executable file of the application program is generated according to source codes of the application program which are developed in the development environment.
In an alternative implementation, the apparatus further includes:
the third acquisition module is used for acquiring a new version of auxiliary plug-in under the condition that the initialization code template is required to be updated, wherein the new version of auxiliary plug-in is provided with the new version of initialization code template;
and the replacing module is used for replacing the auxiliary plug-ins existing in the development environment by using the auxiliary plug-ins of the new version.
In an alternative implementation, the apparatus further includes:
a searching module, configured to, in a case where an executable file of the application program is generated according to source codes of the application program that have been developed in the development environment, respectively find whether there is an initialization code having the preset initialization tag in sub-manifest files in respective classes in the source codes;
A fourth obtaining module, configured to obtain a class name of a class to be initialized recorded in a second code segment in an initialization code of the preset initialization tag, and obtain a class name of the ContentProvider class recorded in a first code segment in the initialization code of the preset initialization tag, and the preset merge tag;
the generating module is used for generating a tag set in the ContentProvider class in the executable file;
And the second adding module is used for adding the obtained class names of the classes to be initialized in the tag set according to the class names of the ContentProvider classes and the preset merging tags.
In a third aspect, the present application shows an electronic device comprising:
A processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the data processing method according to the first aspect.
In a fourth aspect, the application features a non-transitory computer readable storage medium that, when executed by a processor of an electronic device, enables the electronic device to perform the data processing method of the first aspect.
In a fifth aspect, the application shows a computer program product, which when executed by a processor of an electronic device, causes the electronic device to perform the data processing method according to the first aspect.
The technical scheme provided by the application can comprise the following beneficial effects:
In the application, an initialization code template set in an auxiliary plug-in is acquired. And for any one of the at least one component, acquiring the class name of the class to be initialized in the component from the plug-in file corresponding to the auxiliary plug-in the component. And adding the class name of the class to be initialized in the component into a class name adding bit in the initialization code template to obtain the initialization code of the class to be initialized in the component. The method comprises the steps of storing initialization codes of the class to be initialized in a component in a sub-manifest file of the class to be initialized in the component.
By the method and the device, when the initialized attribute and the attribute for merging to the ContentProvider are required to be set for the class to be initialized in each component in the application program in the development environment of the application program, codes of the initialized attribute for the class to be initialized in each component in the development environment of the application program can not be written, and codes of the attribute for merging to the ContentProvider can not be written for the class to be initialized in each component in the application program. And only one initialization code template and the class name of the class to be initialized in the component can be set in the development environment, so that the code development amount can be reduced, and the labor cost is further reduced.
Drawings
FIG. 1 is a flow chart of the steps of a data processing method of the present application.
FIG. 2 is a flow chart of the steps of a data processing method of the present application.
Fig. 3 is a block diagram of a data processing apparatus of the present application.
Fig. 4 is a block diagram of an electronic device of the present application.
Fig. 5 is a block diagram of an electronic device of the present application.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will become more readily apparent, a more particular description of the application will be rendered by reference to the appended drawings and appended detailed description.
Referring to fig. 1, a flowchart of steps of a data processing method of the present application is shown, and the data processing method is applied to an electronic device, where the electronic device runs a development environment of an application program, and the development environment includes at least one component of a ContentProvider (content provider) class, an auxiliary plug-in and the application program, and each component includes at least one class to be initialized.
In the application, a developer can start a development environment in the electronic device and develop source codes of application programs in the development environment.
In one embodiment, a developer has developed a portion of source code of an application program in a development environment, where the developed source code includes at least one component, where each component includes at least one class to be initialized, and where the component may include a Library component, etc.
In the application, for different classes of functions developed by the application program, some classes in the component need to be initialized in the executable file in the process of starting the executable file of the application program, some classes in the component do not need to be initialized in the executable file in the process of starting the executable file of the application program, but can be started or invoked under specific requirements, services or scenes, and the like.
As such, it is desirable to set in a development environment which classes in a component need to be initialized during the executable start-up process and the manner in which they are initialized.
For the initialization method, class initialization and the like can be performed by the ContentProvider class.
In one example, during the development phase, a developer may input a creation request in the development environment of an application for creating a ContentProvider class in the development environment of the application. The electronic device may receive the creation request and then create a ContentProvider class in the development environment of the application according to the creation request.
In one embodiment of the present application, some classes in a component in an application need to be initialized in an executable file during the startup of the executable file of the application, and therefore, it is necessary to set which classes in the component need to be initialized in the development environment of the application during the startup of the executable file of the application.
The class to be initialized may include a class in a Library component in an application, or the like.
In order to realize that which classes in the components need to be initialized in the process of starting the executable file of the application program in the development environment of the application program, initialized attributes can be respectively set for the classes to be initialized in each component in the application program in the development environment.
In order to set the initialized attribute for each class to be initialized in each component in the application program in the development environment, at least the following two tasks need to be prepared in the present application.
In one aspect, an auxiliary plug-in is created in a development environment. The auxiliary inserts include gradle inserts, etc.
For example, a developer may input a creation request in the development environment of an application for creating an auxiliary plug-in the development environment of the application. The electronic device can receive the creation request and then create an auxiliary plug-in the development environment of the application based on the creation request.
In addition, an initialization code template may be set in the auxiliary plug-in.
For example, a developer may enter a setup request in the development environment of the application for setting up a second code segment in the initialization code template in the auxiliary plug-in. The electronic device may receive the setting request and then set a second code segment in the initialization code template in the auxiliary plug-in according to the setting request.
The second code segment at least comprises a class name adding bit and a preset initialization tag used for indicating that the class corresponding to the class name added on the class name adding bit needs to be initialized.
The class name addition bit is used to add class names of classes that need to be initialized, etc.
The class name adding bit and the preset initialization tag can embody the attribute that the class corresponding to the class name added on the class name adding bit needs to be initialized in the process of starting the executable file of the application program.
On the other hand, in the present application, for any one of the at least one component, in the case where the component includes a class to be initialized, a plug-in file corresponding to the auxiliary plug-in may be created in the component, for example, a build.
For example, a developer may enter a creation request in the development environment of an application to create a plug-in corresponding to an auxiliary plug-in the component. The electronic device may receive the creation request and then create a plug-in file corresponding to the auxiliary plug-in the component according to the creation request.
In addition, a developer can input a setting request for setting the class name of the class to be initialized in the component in the plug-in file corresponding to the auxiliary plug-in the component in the development environment of the application program, and the electronic device can receive the setting request and then set the class name of the class to be initialized in the component in the plug-in file corresponding to the auxiliary plug-in the component according to the setting request.
The same is true for each of the other of the at least one component.
In the application, the initialization is completed by using the to-be-initialized class in each component in the executable file of the application program, and the to-be-initialized classes in each component in the executable file of the application program are independent.
Therefore, the class name of the class to be initialized in each component needs to be incorporated into the ContentProvider class, so that the ContentProvider class can initialize the class to be initialized in each component in the executable file of the application program according to the class name of the class to be initialized in each component.
In order to be able to merge class names of classes to be initialized in respective components into the ContentProvider class, in the present application, it is also necessary to set properties for merging to the ContentProvider class for the classes to be initialized in respective components in the application program, respectively, in the development environment of the application program.
In the application, the attribute for merging to the ContentProvider class can be respectively set for the class to be initialized in each component in the application program by means of the auxiliary plug-in the development environment of the application program.
For example, a developer may enter a setup request in the development environment of an application for setting up a first code segment in an initialization code template in an auxiliary plug-in. The electronic device may receive the setup request and then set up a first code segment in the initialization code template in the auxiliary plug-in according to the setup request.
Thus, the initialization code template in the present application includes a first code segment and a second code segment.
The first code segment at least comprises a class name of the ContentProvider class and a preset merging tag used for indicating merging to the ContentProvider class according to the class name of the ContentProvider class.
The class name of the ContentProvider class and the preset merge tag may embody an attribute for merging into the ContentProvider class.
As such, referring to fig. 1, a specific flow of setting an initialized attribute and an attribute for merging to a ContentProvider class for a class to be initialized in each component in an application program in a development environment of the application program, respectively, may include:
In step S101, an initialization code template set in the auxiliary plug-in is acquired.
The initialization code template includes a first code segment and a second code segment.
The first code segment at least comprises a class name of the ContentProvider class and a preset merging tag used for indicating merging to the ContentProvider class according to the class name of the ContentProvider class.
The second code segment at least comprises a class name adding bit and a preset initialization tag used for indicating that the class corresponding to the class name added on the class name adding bit needs to be initialized.
In step S102, for any one of the at least one component, a class name of a class to be initialized in the component is obtained in a plug-in file corresponding to an auxiliary plug-in the component.
In the present application, for any one of at least one component, the flow of step S102 to step S104 may be executed, so as to achieve the purpose of setting the initialized attribute and the attribute for merging to the ContentProvider class for the class to be initialized in the component. The same is true for each of the other of the at least one component.
For any one of at least one component, the component is provided with a plug-in file corresponding to the auxiliary plug-in, since the plug-in file in the component is the plug-in file corresponding to the auxiliary plug-in, that is, the plug-in file in the component is associated with the auxiliary plug-in, the auxiliary plug-in is provided with an initialization code template, and since the initialization code template comprises a second code segment, the second code segment at least comprises a class name adding bit and a preset initialization tag for indicating that a class corresponding to the class name added on the class name adding bit needs to be initialized. The class name adding bit and the preset initialization tag can embody the attribute that the class corresponding to the class name added on the class name adding bit needs to be initialized in the process of starting the executable file of the application program.
Thus, it is often described that the class corresponding to the class name in the component is a class to be initialized, that is, the class corresponding to the class name in the component needs to be initialized in the executable file in the process of starting the executable file of the application program.
In this way, in order to set the initialized attribute and the attribute for merging to the ContentProvider class for the class to be initialized in the component, the class name of the class to be initialized in the component may be obtained from the plug-in file corresponding to the auxiliary plug-in the component, and then step S103 is executed.
In step S103, the class name of the class to be initialized in the component is added in the class name adding bit in the initialization code template, so as to obtain the initialization code of the class to be initialized in the component.
The initialization code includes a first code segment and a second code segment.
The first code segment in the initialization code at least comprises a class name of the ContentProvider class and a preset merging tag used for indicating merging to the ContentProvider class according to the class name of the ContentProvider class.
The second code segment in the initialization code at least comprises a class name of the class to be initialized and a preset initialization tag used for indicating that the class corresponding to the class name of the class to be initialized needs to be initialized.
The application can have the following association relation of auxiliary plug-ins, initialization code templates, plug-in files corresponding to the auxiliary plug-ins and class names of classes to be initialized in the component.
In this way, the initialization code template and the class name of the class to be initialized in the component can be associated through the auxiliary plug-in and the plug-in file corresponding to the auxiliary plug-in, that is, the electronic device can know that the class name of the class to be initialized in the component needs to be added in the class name adding bit in the second code segment in the initialization code template.
Thus, the electronic device can add the class name of the class to be initialized in the component in the class name adding bit in the second code segment in the initialization code template, and obtain the initialization code of the class to be initialized in the component.
The initialization code of the class to be initialized in the component can embody the attribute of the initialization of the class to be initialized in the component and the attribute for merging to the ContentProvider class. Thereby achieving the purpose of setting the initialized attribute for the class to be initialized in the component in the application program and the attribute for merging to the ContentProvider class in the development environment of the application program.
In step S104, the initialization code of the class to be initialized in the component is stored in the sub-manifest file of the class to be initialized in the component.
In the application, an initialization code template set in an auxiliary plug-in is acquired. And for any one of the at least one component, acquiring the class name of the class to be initialized in the component from the plug-in file corresponding to the auxiliary plug-in the component. And adding the class name of the class to be initialized in the component into a class name adding bit in the initialization code template to obtain the initialization code of the class to be initialized in the component. The method comprises the steps of storing initialization codes of the class to be initialized in a component in a sub-manifest file of the class to be initialized in the component.
By the method and the device, when the initialized attribute and the attribute for merging to the ContentProvider are required to be set for the class to be initialized in each component in the application program in the development environment of the application program, codes of the initialized attribute for the class to be initialized in each component in the development environment of the application program can not be written, and codes of the attribute for merging to the ContentProvider can not be written for the class to be initialized in each component in the application program. And only one initialization code template and the class name of the class to be initialized in the component can be set in the development environment, so that the code development amount can be reduced, and the labor cost is further reduced.
In another embodiment of the present application, after storing the initialization codes of the class to be initialized in each component in the sub-manifest files of the class to be initialized in each component, respectively, a developer may resume the source codes of other functions of the application program in the development environment.
After a developer writes the source code of the application program in the development environment, the source code of the application program developed in the development environment may be compiled to obtain an executable file of the application program. Referring to fig. 2, the specific flow is as follows:
In step S201, in the case of generating an executable file of an application program from a source code of an application program that has been developed in a development environment, it is searched for whether or not there is an initialization code having a preset initialization tag in sub-manifest files in respective classes in the source code, respectively.
The source code of the application program developed in the development environment at least comprises a ContentProvider class, an auxiliary plug-in and at least one component of the application program, wherein each component respectively comprises at least one class to be initialized and the like, and the auxiliary plug-in comprises an initialization code template. Each component comprises a plug-in file corresponding to the auxiliary plug-in, and the plug-in file comprises class names of classes to be initialized in the component and the like. Of course, code for other functions of the application program may also be included, such as other classes that do not need to be initialized during startup of the executable of the application program, and so forth, which are not described in detail herein.
In the application, after a developer writes the source code of the application program in the development environment, the developer can input a compiling request for compiling the source code of the application program developed in the development environment into the electronic device, and the electronic device can receive the compiling request and compile the source code of the application program developed in the development environment according to the compiling request to obtain the executable file of the application program.
In the sub-manifest file of the class to be initialized in the development environment, initializing codes of the class to be initialized are provided. Which may embody initialized properties, properties for merging to the ContentProvider class, etc.
The initialization code of the class to be initialized comprises a first code segment and a second code segment.
The first code segment at least comprises a class name of the ContentProvider class and a preset merging tag used for indicating merging to the ContentProvider class according to the class name of the ContentProvider class.
The second code segment at least comprises a class name of the class to be initialized and a preset initialization tag used for indicating that the class corresponding to the class name of the class to be initialized needs to be initialized.
In this way, in the case where the electronic device compiles the source code of an application program that has been developed in the development environment, the class to be initialized may be searched in the source code, for example, whether or not there is an initialization code with a preset initialization tag in the sub-manifest files in the respective classes in the source code, respectively.
For example, for any one class of the components in the application program, if an initialization code with a preset initialization tag exists in a sub-manifest file of the class, the class is often the class to be initialized, and if no initialization code with a preset initialization tag exists in a sub-manifest file of the class, the class is often not the class to be initialized. The same is true for each of the other classes in the various components in the application.
Therefore, in this step, the electronic device may find whether there is an initialization code having a preset initialization tag in the sub-manifest files in each class in the source code of the application program that has been developed in the development environment, respectively. Step S202 is then performed.
In step S202, a class name of a class to be initialized recorded in a second code segment in an initialization code in which a preset initialization tag exists is obtained, and a class name of a ContentProvider class recorded in a first code segment in the initialization code in which the preset initialization tag exists and a preset merge tag are obtained.
In the application, for any class to be initialized in each component in the application program, the class name and the preset merging tag of the ContentProvider class recorded in the first code segment of the initialization code in the sub-manifest file of the class to be initialized can be obtained, and the class name of the class to be initialized in the second code segment can be obtained.
The above operations are also performed for each of the other to-be-initialized classes in the respective components in the application.
In step S203, a tag set is generated in the ContentProvider class in the executable file.
In step S204, according to the class name of the ContentProvider class and the preset merge tag, the obtained class names of the classes to be initialized are added in the tag set.
In the application, for any one class to be initialized in each component in an application program, according to the class name of the ContentProvider class recorded in the first code segment of the initialization code in the sub-manifest file of the class to be initialized and the preset merging tag, the class name of the class to be initialized can be known to be merged into the ContentProvider class corresponding to the class name of the ContentProvider class, so that a tag set in the ContentProvider class can be searched according to the class name of the ContentProvider class, and then the class name of the class to be initialized is added in the tag set according to the preset merging tag.
The above operations are also performed for each of the other to-be-initialized classes in the respective components in the application.
In this way, the tag set of the ContentProvider class has class names of classes to be initialized in each component in the application program, so that when the classes to be initialized in the executable file need to be initialized later in the case of starting the executable file of the application program, the tag set of the ContentProvider class in the executable file can be acquired, the class names of the classes to be initialized in each component are acquired in the tag set of the ContentProvider class, the classes to be initialized in each component in each executable file are acquired according to the class names of the classes to be initialized in each component in the tag set, and the classes to be initialized in each component acquired based on the ContentProvider class initialization in the executable file. Thereby realizing the task of initializing each class to be initialized in the components in the executable file based on the ContentProvider class.
In another embodiment of the present application, in the case of generating an executable file of an application program according to source code of an application program that has been developed in a development environment of the application program, since the executable file is already obtained, an initialization code template set in the development environment of the application program often no longer has an effect, so that, in order to save storage space, at least the auxiliary plug-in may be deleted or the initialization code template may be deleted in the auxiliary plug-in.
In another embodiment of the present application, the initialization code template may need to be updated according to actual requirements, for example, related information of the initialized attribute needs to be changed, so that codes in the initialization code template may be modified.
Under the condition that the initialization code template needs to be updated, a new version of auxiliary plug-in can be obtained, and the new version of initialization code template is arranged in the new version of auxiliary plug-in. The new version of the auxiliary plug-in may be entered or downloaded by the user in the electronic device. The new version of the auxiliary plug-in is then used to replace the auxiliary plug-in that already exists in the development environment.
Therefore, the auxiliary plug-in is updated, the initialization code template is updated, a large amount of manual modification is avoided, and therefore efficiency can be improved, and labor cost can be reduced.
In another embodiment of the application, the electronic device runs a development environment of the application program, the development environment comprises at least two ContentProvider classes, an auxiliary plug-in and at least one component of the application program, each component comprises at least one class to be initialized, and at least two initialization code templates are arranged in the auxiliary plug-in. Different ContentProvider classes correspond to different initialization code templates.
The method comprises the steps of setting an initialization code template in an auxiliary plug-in, setting any initialization code template in the auxiliary plug-in, setting the initialization code template to comprise a first code segment and a second code segment, setting at least a class name of a ContentProvider class corresponding to the initialization code template in at least two ContentProvider classes and a preset merging label used for indicating merging of the class name of the ContentProvider class corresponding to the initialization code template into the ContentProvider class corresponding to the initialization code template, setting at least a class name adding bit and a preset initialization label used for indicating that a class corresponding to the class name added on the class name adding bit needs to be initialized in the first code segment, and setting the same for each other initialization code template in the auxiliary plug-in.
Wherein the class names of the ContentProvider classes in the first code segment in the different initialization code templates are different.
For any one component, the class name of the class to be initialized in the component is obtained in the plug-in file corresponding to the auxiliary plug-in the component, and for each other component, the same is true, so that the class names of a plurality of initialization classes are obtained.
Class names of the plurality of initialization classes are divided into more than two class name sets. Each class name set comprises more than two class names, and the class names in different class name sets are not overlapped.
The ContentProvider class corresponding to the different class name sets is different, and the initialization code templates corresponding to the different class name sets are different.
For any one of the more than two class name sets, the ContentProvider class corresponding to the class name set and the initialization code template corresponding to the class name set can be determined.
The method comprises the steps of adding class names of any class to be initialized in a class name adding bit in an initialization code template to obtain an initialization code of the class to be initialized, wherein the initialization code of the class to be initialized comprises a first code section and a second code section, the first code section at least comprises class names of contentproviders corresponding to the class name set and preset merging labels used for indicating merging of the class names of the contentproviders corresponding to the class name set to the contentproviders corresponding to the class name set, the second code section at least comprises the class names of the class to be initialized and preset initialization labels used for indicating that the class corresponding to the class names of the class to be initialized needs to be initialized, and then the initialization code of the class to be initialized is stored in a sub-list file of the class to be initialized. The above operations are also performed for each class name of the other classes to be initialized in the class name set.
The above operations are performed similarly for each of the other of the more than two sets of class names.
It should be noted that, for simplicity of explanation, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the present application is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the application. Further, those skilled in the art will appreciate that the embodiments described in the specification are all alternative embodiments and that the actions involved are not necessarily required for the present application.
Referring to fig. 3, there is shown a block diagram of a data processing apparatus of the present application, applied to an electronic device, the electronic device running a development environment of an application program, the development environment including at least one content provider ContentProvider class, an auxiliary plug-in, and at least one component of the application program, each component including at least one class to be initialized, the apparatus comprising:
The first obtaining module 11 is configured to obtain an initialization code template set in the auxiliary plug-in, where the initialization code template includes a first code section and a second code section, where the first code section includes at least a class name of the ContentProvider class and a preset merge tag for indicating that the ContentProvider class is merged according to the class name, and the second code section includes at least a class name adding bit and a preset initialization tag for indicating that a class corresponding to the class name added on the class name adding bit needs to be initialized;
the second obtaining module 12 is configured to obtain, for any one of the at least one component, a class name of a class to be initialized in the component, in a plug-in file corresponding to the auxiliary plug-in the component;
The first adding module 13 is configured to add a class name of a class to be initialized in the component to a class name adding bit in the initialization code template, so as to obtain an initialization code of the class to be initialized in the component, where the initialization code includes a first code section and a second code section, the first code section in the initialization code includes at least a class name of the ContentProvider class and a preset merging tag for indicating merging to the ContentProvider class according to the class name of the ContentProvider class, and the second code section in the initialization code includes at least the class name of the class to be initialized and a preset initialization tag for indicating that a class corresponding to the class name of the class to be initialized needs to be initialized;
A storage module 14, configured to store, in a sub-manifest file of a class to be initialized in the component, an initialization code of the class to be initialized in the component.
In an alternative implementation, the apparatus further includes:
The first setting module is used for creating an auxiliary plug-in the development environment, and setting the initialization code template in the auxiliary plug-in;
And
And the second setting module is used for creating a plug-in file corresponding to the auxiliary plug-in any one of the at least one component, and setting a class name of a class to be initialized in the component in the plug-in file.
In an alternative implementation, the apparatus further includes:
And the deleting module is used for deleting the auxiliary plug-in or deleting the initialization code template in the auxiliary plug-in under the condition that an executable file of the application program is generated according to source codes of the application program which are developed in the development environment.
In an alternative implementation, the apparatus further includes:
the third acquisition module is used for acquiring a new version of auxiliary plug-in under the condition that the initialization code template is required to be updated, wherein the new version of auxiliary plug-in is provided with the new version of initialization code template;
and the replacing module is used for replacing the auxiliary plug-ins existing in the development environment by using the auxiliary plug-ins of the new version.
In an alternative implementation, the apparatus further includes:
a searching module, configured to, in a case where an executable file of the application program is generated according to source codes of the application program that have been developed in the development environment, respectively find whether there is an initialization code having the preset initialization tag in sub-manifest files in respective classes in the source codes;
A fourth obtaining module, configured to obtain a class name of a class to be initialized recorded in a second code segment in an initialization code of the preset initialization tag, and obtain a class name of the ContentProvider class recorded in a first code segment in the initialization code of the preset initialization tag, and the preset merge tag;
the generating module is used for generating a tag set in the ContentProvider class in the executable file;
And the second adding module is used for adding the obtained class names of the classes to be initialized in the tag set according to the class names of the ContentProvider classes and the preset merging tags.
In the application, an initialization code template set in an auxiliary plug-in is acquired. And for any one of the at least one component, acquiring the class name of the class to be initialized in the component from the plug-in file corresponding to the auxiliary plug-in the component. And adding the class name of the class to be initialized in the component into a class name adding bit in the initialization code template to obtain the initialization code of the class to be initialized in the component. The method comprises the steps of storing initialization codes of the class to be initialized in a component in a sub-manifest file of the class to be initialized in the component.
By the method and the device, when the initialized attribute and the attribute for merging to the ContentProvider are required to be set for the class to be initialized in each component in the application program in the development environment of the application program, codes of the initialized attribute for the class to be initialized in each component in the development environment of the application program can not be written, and codes of the attribute for merging to the ContentProvider can not be written for the class to be initialized in each component in the application program. And only one initialization code template and the class name of the class to be initialized in the component can be set in the development environment, so that the code development amount can be reduced, and the labor cost is further reduced.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
Fig. 4 is a block diagram of an electronic device 800 in accordance with the present application. For example, electronic device 800 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to FIG. 4, the electronic device 800 may include one or more of a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, images, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen between the electronic device 800 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. The front camera and/or the rear camera may receive external multimedia data when the device 800 is in an operational mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 further includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to, a home button, a volume button, an activate button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the electronic device 800. For example, the sensor assembly 814 may detect an on/off state of the device 800, a relative positioning of the components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in position of the electronic device 800 or a component of the electronic device 800, the presence or absence of a user's contact with the electronic device 800, an orientation or acceleration/deceleration of the electronic device 800, and a change in temperature of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices, either wired or wireless. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi, an operator network (e.g., 2G, 3G, 4G, or 5G), or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast signals or broadcast operation information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 804 including instructions executable by processor 820 of electronic device 800 to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
Fig. 5 is a block diagram of an electronic device 1900 in accordance with the present application. For example, electronic device 1900 may be provided as a server.
Referring to FIG. 5, electronic device 1900 includes a processing component 1922 that further includes one or more processors and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by processing component 1922. The application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions. Further, processing component 1922 is configured to execute instructions to perform the methods described above.
The electronic device 1900 may also include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input/output (I/O) interface 1958. The electronic device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, or the like.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing describes the data processing method, apparatus, electronic device and storage medium, and specific examples are provided herein to illustrate the principles and embodiments of the present application, and the above examples are provided to assist in understanding the method and core ideas of the present application, and meanwhile, to those skilled in the art, according to the ideas of the present application, there are variations in the specific embodiments and application scope, so the disclosure should not be construed as limiting the application.
Claims (12)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111427879.4A CN114115862B (en) | 2021-11-26 | 2021-11-26 | Data processing method, device, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111427879.4A CN114115862B (en) | 2021-11-26 | 2021-11-26 | Data processing method, device, electronic device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114115862A CN114115862A (en) | 2022-03-01 |
CN114115862B true CN114115862B (en) | 2025-09-26 |
Family
ID=80370667
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111427879.4A Active CN114115862B (en) | 2021-11-26 | 2021-11-26 | Data processing method, device, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114115862B (en) |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9058177B2 (en) * | 2004-02-12 | 2015-06-16 | Raju Venkata Chiluvuri | Real software components for achieving real component-based design |
US8676808B2 (en) * | 2009-07-09 | 2014-03-18 | Dillon Software Services, Llc | Data store interface that facilitates distribution of application functionality across a multi-tier client-server architecture |
US9344422B2 (en) * | 2013-03-15 | 2016-05-17 | Oracle International Corporation | Method to modify android application life cycle to control its execution in a containerized workspace environment |
US9495185B2 (en) * | 2015-02-23 | 2016-11-15 | International Business Machines Corporation | Per tenant initialization check removal |
CN105354073B (en) * | 2015-10-27 | 2018-11-06 | 中通服公众信息产业股份有限公司 | A kind of stand-alone application networking method based on android system and system |
US11194766B2 (en) * | 2018-11-06 | 2021-12-07 | Dropbox, Inc. | Technologies for integrating cloud content items across platforms |
-
2021
- 2021-11-26 CN CN202111427879.4A patent/CN114115862B/en active Active
Non-Patent Citations (2)
Title |
---|
Android | App Startup 可能比你想象中要简单;彭旭锐;《https://www.jianshu.com/p/98d3623fa2d4》;20201025;第1-18 页 * |
App Startup真的能减少启动耗时吗;jimuzz;《https://www.cnblogs.com/jimuzz/p/14166746.html》;20201221;第1-7页 * |
Also Published As
Publication number | Publication date |
---|---|
CN114115862A (en) | 2022-03-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110704053B (en) | Style information processing method and device | |
CN111459494B (en) | A code processing method and device | |
CN105468410A (en) | System upgrading method and device | |
CN109947722B (en) | Data compression method and device for application program and computer readable storage medium | |
CN113778440B (en) | Data processing method and device, electronic equipment and storage medium | |
CN118170435B (en) | Instruction information processing method, device, equipment and storage medium | |
CN111221613A (en) | Program calling method and device and storage medium | |
CN107368562B (en) | Page display method, device and terminal | |
CN113590091A (en) | Data processing method and device, electronic equipment and storage medium | |
CN114115862B (en) | Data processing method, device, electronic device and storage medium | |
CN114885211B (en) | Media resource template generation method, media resource generation method and device | |
CN114139506B (en) | Document processing method, device, storage medium and program product | |
CN117271005A (en) | Container-based application running method and device, electronic equipment and storage medium | |
CN113128181B (en) | Information processing method and device | |
CN114115863B (en) | Data processing method, device, electronic device and storage medium | |
CN110457084B (en) | Loading method and device | |
CN112214252B (en) | Information expansion method and device and electronic equipment | |
CN108427568B (en) | User interface updating method and device | |
CN115098200B (en) | Language switching method and device, electronic equipment and storage medium | |
CN111625251B (en) | Method and device for processing application instance | |
CN115809054B (en) | Data processing method and device, electronic equipment and storage medium | |
CN113934452B (en) | Data processing method and device, electronic equipment and storage medium | |
CN111596949B (en) | Method and device for developing application program | |
CN114661338B (en) | A program package processing method, device, electronic device and storage medium | |
CN114489595B (en) | Data processing method, device, electronic device, storage medium and product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant |