CN109117144B - Page processing method, device, terminal and storage medium - Google Patents

Page processing method, device, terminal and storage medium Download PDF

Info

Publication number
CN109117144B
CN109117144B CN201810753514.2A CN201810753514A CN109117144B CN 109117144 B CN109117144 B CN 109117144B CN 201810753514 A CN201810753514 A CN 201810753514A CN 109117144 B CN109117144 B CN 109117144B
Authority
CN
China
Prior art keywords
task
task identifier
callback
function
page
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
Application number
CN201810753514.2A
Other languages
Chinese (zh)
Other versions
CN109117144A (en
Inventor
余鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN201810753514.2A priority Critical patent/CN109117144B/en
Publication of CN109117144A publication Critical patent/CN109117144A/en
Application granted granted Critical
Publication of CN109117144B publication Critical patent/CN109117144B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The disclosure relates to a page processing method, a page processing device, a terminal and a storage medium. The method comprises the following steps: triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system; and the application program calls the API function and transmits a task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system finishes executing the API function. The present disclosure improves developer software design flexibility.

Description

Page processing method, device, terminal and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a page processing method, an apparatus, a terminal, and a storage medium.
Background
With the continuous development of terminals, more and more applications are provided by the terminals.
In the related art, when a developer develops an Application program of a terminal, the developer needs to call an Application Programming Interface (API) function provided by an operating system of the terminal. In addition, in order to trigger the execution of other functions after the API function is executed, so as to implement the callback function of the function, when the API function is called, the function pointers of other functions may be passed to the API function as entries.
Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides a page processing method, apparatus, terminal and storage medium.
According to a first aspect of the embodiments of the present disclosure, there is provided a page processing method, including:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits a task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system completes execution of the API function.
Optionally, the method further includes: and when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function.
Optionally, the method further includes: setting a callback attribute for the page when the application program initializes the page;
storing the corresponding relationship between the task identifier and the callback function, including:
and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
According to a second aspect of the embodiments of the present disclosure, there is provided a page processing method, including:
the operating system obtains a task identifier of a target task transmitted by an application program; the target task is triggered in the page of the application program and needs to call the API function of the operating system;
and after the API function is executed, the operating system determines a callback function corresponding to the task identifier according to the task identifier and calls the callback function.
Optionally, the method further includes: and the operating system determines the callback function corresponding to the task identifier according to the task identifier and the corresponding relation between the task identifier and the callback function.
Optionally, the corresponding relationship between the task identifier and the callback function is stored in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
According to a third aspect of the embodiments of the present disclosure, there is provided a page processing method, including:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits the task identifier of the target task to the operating system;
and after the operating system executes the API function, determining a callback function corresponding to the task identifier according to the task identifier, and calling the callback function.
Optionally, the method further includes: when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function;
the determining the callback function corresponding to the task identifier according to the task identifier includes: and determining a callback function corresponding to the task identifier according to the task identifier and the corresponding relation.
Optionally, the method further includes: setting a callback attribute for the page when the application program initializes the page;
storing the corresponding relationship between the task identifier and the callback function, including: and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a page processing apparatus including:
the trigger module is configured to trigger a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
and the calling module is configured to call the API function by the application program, transmit the task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system completes execution of the API function.
Optionally, the apparatus further includes a generating module configured to generate the task identifier when the target task is triggered, and store a corresponding relationship between the task identifier and the callback function.
Optionally, the apparatus further includes a setting module configured to set a callback attribute for the page when the page is initialized;
the generation module comprises a storage submodule configured to store the correspondence between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
According to a fifth aspect of the embodiments of the present disclosure, there is provided a page processing apparatus including:
the obtaining module is configured to obtain a task identifier of a target task transmitted by an application program; the target task is triggered in the page of the application program and needs to call an API function of an operating system;
and the callback module is configured to determine a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and call the callback function.
Optionally, the callback module further includes a determining submodule configured to determine, according to the task identifier and the corresponding relationship between the task identifier and the callback function, the callback function corresponding to the task identifier.
Optionally, the corresponding relationship between the task identifier and the callback function is stored in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
According to a sixth aspect of the embodiments of the present disclosure, there is provided a page processing apparatus including: the call module comprises a trigger module, a calling module and a callback module;
the trigger module is configured to trigger a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the calling module is configured to call the API function and transfer the task identifier of the target task to the callback module;
and the callback module is configured to determine a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and call the callback function.
Optionally, the apparatus further includes a generating module configured to generate the task identifier when the target task is triggered, and store a corresponding relationship between the task identifier and the callback function;
the callback module further comprises a determining submodule configured to determine a callback function corresponding to the task identifier according to the task identifier and the corresponding relationship.
Optionally, the apparatus further includes a setting module configured to set a callback attribute for the page when the page is initialized;
the generation module comprises: and the storage submodule is configured to store the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
According to a seventh aspect of the embodiments of the present disclosure, there is provided a terminal, including:
a processor and a memory for storing computer instructions; the processor executes the computer instructions to perform the method of any of the first, second or third aspects described above.
According to an eighth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of any one of the above first, second or third aspects.
According to the page processing method, the device, the terminal and the storage medium, the target task is triggered in the page of the application program, the target task is a task needing to call an Application Programming Interface (API) function of an operating system, the API function is called by the application program, and the task identifier of the target task is transmitted to the operating system, so that the operating system can call a callback function according to the task identifier after the API function is executed, and the flexibility of software design of developers is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a block diagram illustrating a method of page processing in accordance with an exemplary embodiment;
FIG. 2 is a block diagram illustrating a page processing method in accordance with another exemplary embodiment;
FIG. 3 is a block diagram illustrating a page processing method in accordance with yet another exemplary embodiment;
FIG. 4 is a block diagram illustrating a page processing apparatus according to an example embodiment;
FIG. 5 is a block diagram illustrating a page processing apparatus according to another exemplary embodiment;
FIG. 6 is a block diagram illustrating a page processing apparatus according to yet another exemplary embodiment;
FIG. 7 is a block diagram illustrating a page processing apparatus according to yet another exemplary embodiment;
FIG. 8 is a block diagram illustrating a page processing apparatus according to yet another exemplary embodiment;
FIG. 9 is a block diagram illustrating a page processing apparatus in accordance with yet another exemplary embodiment;
FIG. 10 is a block diagram illustrating a page processing apparatus in accordance with yet another exemplary embodiment;
FIG. 11 is a block diagram illustrating a page processing apparatus in accordance with yet another exemplary embodiment;
FIG. 12 is a block diagram illustrating a terminal in accordance with an exemplary embodiment;
FIG. 13 is a block diagram illustrating a terminal in accordance with another exemplary embodiment;
FIG. 14 is a block diagram illustrating a terminal in accordance with yet another exemplary embodiment;
fig. 15 is a block diagram illustrating a terminal 800 according to yet another example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
FIG. 1 is a block diagram illustrating a method of page processing according to an example embodiment. The execution main body of the page processing method provided by this embodiment may be an application program of the terminal. The terminal can be a mobile phone, a tablet computer and the like. As shown in fig. 1, the method of this embodiment may include:
in step 101, in a page of an application program, a target service is triggered, where the target service is a task that needs to call an API function of an operating system.
In this embodiment, an Application program (App) may be composed of a plurality of pages, each page corresponds to one code file (for example, a js file) in a configuration file, that is, the configuration file of one Application includes a plurality of code files, and each code file includes page data and operating logic required for displaying the corresponding page. The application program in this embodiment, for example, may be a fast application, and the application program does not need to be installed in advance when running. The target task may be a task corresponding to any function of the API function that needs to call the terminal operating system and is provided in the page. Optionally, the target task may specifically include at least one of the following: the application program may provide a task corresponding to a function provided by the user (for example, prompt the user of a nearby movie theater), or may also provide a task corresponding to an internal function of the application program (for example, count the stay time of a page), or may also provide a task corresponding to a function provided by the application program to another application program (for example, send the obtained date to another application program), but this is not a limitation to the present disclosure, and the target task may also be another task.
It should be noted that the application program may specifically be a native application program, a web application program, or a hybrid application program, and the disclosure is not limited thereto. When the application is a native application, the application may be a native application written based on a native language of the operating system, or may be a native application written based on a non-native language of the operating system, which is not limited by the present disclosure. When the operating system is an Android operating system, the non-native Language of the operating system may be, for example, HyperText Markup Language (HTML), Cascading Style Sheets (CSSs), or JavaScript.
In step 102, the application program calls the API function, and transmits the task identifier of the target task to the operating system, where the task identifier is used for determining, by the operating system, a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and calls the callback function.
In this step, optionally, the callback function and the API function are commonly used to complete part of or all of the target tasks. For example, when the target task is to prompt a user of a movie theater to be attached, the API function may be configured to complete a subtask of acquiring a current location in the task, and the callback function may be configured to complete determining a nearby movie theater according to the current location acquired by the API function, and prompt the user of the subtask of the nearby movie theater; or, the API function may be configured to complete a subtask of obtaining the current location in the target task, the callback function may be configured to complete a subtask of determining a nearby movie theater according to the current location obtained by the API function, and another function may be configured to complete a nearby movie theater determined according to the callback function, and prompt the user of the subtask of the nearby movie theater.
It should be noted that, in the embodiment of the present disclosure, the API function may call the callback function corresponding to the task identifier according to the task identifier, so that in the embodiment of the present disclosure, the API function may be modified, and the function of the page may be enhanced, and the function that cannot be implemented by the HTML5 in the related art may now be implemented.
Optionally, the task identifier of the target task may be passed to the operating system by using the task identifier of the target task as an entry parameter (i.e., entry parameter) of the API function, or the task identifier of the target task may be passed to the operating system by generating a message to the operating system, and so on. In this step, the task identifier of the target task may be transferred to the operating system, so that the operating system may determine the callback function corresponding to the task identifier according to the task identifier and call the callback function.
Optionally, the task identifier may be generated statically or dynamically.
According to the page processing method provided by the embodiment, the target task is triggered in the page of the application program, the target task is a task needing to call an Application Programming Interface (API) function of the operating system, the API function is called by the application program, and the task identifier of the target task is transmitted to the operating system, so that the operating system can call the callback function according to the task identifier after the API function is executed, and compared with the method of calling the callback function through a function pointer of the callback function, the flexibility of software design of developers is improved.
In addition, in the related art, in order to improve development efficiency, developers may use the transliterated script language Javascript to develop Native applications of an Android operating system based on a fact Native (RN) development framework proposed by facebook corporation. The fact Native development framework provides a bridge for interaction between Javascript and Native languages of the android operating system. A developer uses a program written in a non-Native language under a read Native development framework, and can call an Application Programming Interface (API) function provided by an operating system based on the read Native development framework.
In the embodiment of the disclosure, when the program is a Native application program written in a non-Native language based on the operating system, by triggering a target task that needs to call an API function of the operating system in a page of the application program, a task identifier of the target task is sent to the API function, so that the operating system can call a callback function according to the task identifier after the API function is executed, and call of the program written in the non-Native language to the API function of the operating system is realized on the basis that a read Native development framework is not based. Meanwhile, the problem that the non-Native language is limited to the Javascript language by the read Native development framework is avoided, so that developers can write Native applications based on the non-Javascript non-Native language (such as HTML language).
Fig. 2 is a block diagram illustrating a page processing method according to another exemplary embodiment. The execution main body of the page processing method provided by this embodiment may be an operating system of the terminal. The terminal can be a mobile phone, a tablet computer and the like. As shown in fig. 2, the method of this embodiment may include:
in step 201, the operating system obtains a task identifier of a target task transferred by an application program; the target task is a task which is triggered in the page of the application program and needs to call an API function of the operating system.
In this step, optionally, the identifier of the target task transferred by the application program may be obtained through an entry parameter of the API function, or the identifier of the target task transferred by the application program may also be obtained in a manner of receiving a message from the application program, and so on.
In step 202, after the API function is executed, the operating system determines a callback function corresponding to the task identifier according to the task identifier, and calls the callback function.
In this step, optionally, the callback function corresponding to the task identifier may be determined according to the corresponding relationship between the task identifier and the callback function. Further optionally, the corresponding relationship may specifically be a corresponding relationship between the task identifier and an identifier (e.g., a function pointer) of the callback function corresponding to the task identifier. When the task identifier is generated statically, after the application program is started, the corresponding relation between the task identifier and the callback function can be generated; when the task identifier is dynamically generated, after the task identifier is generated, a corresponding relationship between the task identifier and the callback function may be generated.
Different from the prior art in which the operating system obtains the function pointer of the callback function corresponding to the API function through the entry parameter of the API function, the operating system in the present disclosure determines the callback function corresponding to the API function by obtaining the task identifier transferred by the application program.
According to the page processing method provided by the embodiment, the task identifier of the target task transmitted by the application program is obtained through the operating system, the target task is a task which is triggered in the page of the application program and needs to call an API function of the operating system, after the API function is executed, the operating system determines the callback function corresponding to the task identifier according to the task identifier and calls the callback function, so that the callback function can be called according to the task identifier after the API function is executed, and compared with the method that the callback function is called through a function pointer of the callback function, the flexibility of software design of developers is improved.
Fig. 3 is a block diagram illustrating a page processing method according to yet another exemplary embodiment. Referring to fig. 3, the method provided in this embodiment mainly describes an interaction process between an application program and an operating system on the basis of the methods shown in fig. 1 and fig. 2. As shown in fig. 3, the method of this embodiment may include:
in step 301, a target task is triggered in a page of an application program, where the target task is a task that needs to call an application programming interface API function of an operating system.
It should be noted that step 301 is similar to step 101, and is not described herein again.
Optionally, when the task identifier of the target task is dynamically generated, the method of this embodiment may further include: and when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function. The present disclosure is not limited with respect to the particular manner in which the task identifier for the task is generated. For example, a task identifier may be randomly generated as the task identifier for the task. The present disclosure may not be limited to a specific manner of storing the corresponding relationship between the task identifier and the callback function. For example, a correspondence of the task identification to an identification of the callback function (e.g., a function pointer) may be stored.
Optionally, the method of this embodiment may further include: when the application program initializes the page, a callback attribute is set for the page, and the callback attribute callbacks of the page can be used for storing the corresponding relation between the task identifier of the task in the page and the callback function. Correspondingly, storing the corresponding relationship between the task identifier and the callback function includes: and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page. Optionally, the callback attribute of the page may store a corresponding relationship between the task identifier and the callback function of each of the plurality of tasks in the page. For example, first, when a task 1 that needs to call an API function 1 of an operating system is triggered, a task identifier 1 of the task 1 is generated, and a correspondence between the task identifier 1 and a callback function 1 corresponding to the task 1 is stored in a callback attribute of the page. And then, when a task 2 of the API function 2 of the operating system needs to be called is triggered, generating a task identifier 2 of the task 2, and storing the corresponding relation between the task identifier 2 and the callback function 2 corresponding to the task 2 in the callback attribute of the page.
In step 302, the application calls the API function and passes the task identification of the target task to the operating system.
It should be noted that step 302 is similar to step 202, and is not described herein again.
In step 303, after the operating system executes the API function, the operating system determines a callback function corresponding to the task identifier according to the task identifier, and calls the callback function.
In this step, optionally, the operating system may determine, according to the task identifier and the corresponding relationship between the task identifier and the callback function, the callback function corresponding to the task identifier. Further optionally, the operating system may obtain a correspondence between the task identifier and the callback function from the callback attribute of the page, and determine the callback function corresponding to the task identifier according to the correspondence.
According to the page processing method provided by the embodiment, the target task is triggered in the page of the application program, the target task is a task needing to call an Application Programming Interface (API) function of the operating system, the API function is called by the application program, the task identifier of the target task is transmitted to the operating system, after the API function is executed by the operating system, the callback function corresponding to the task identifier is determined according to the task identifier, and the callback function is called, so that the callback function can be called by the operating system according to the task identifier after the API function is executed, and compared with the method of calling the callback function through a function pointer of the callback function, the flexibility of software design of developers is improved.
The following are embodiments of the disclosed apparatus that may be used to perform embodiments of the disclosed methods. For details not disclosed in the embodiments of the apparatus of the present disclosure, refer to the embodiments of the method of the present disclosure.
Fig. 4 is a block diagram illustrating a page processing apparatus according to an example embodiment. The apparatus may be implemented as part or all of the terminal by software, hardware or a combination of both. Referring to fig. 4, the apparatus includes: a triggering module 401 and a calling module 402. Wherein the content of the first and second substances,
the triggering module 401 is configured to trigger a target task in a page of an application program, where the target task is a task that needs to call an application programming interface API function of an operating system;
a calling module 402, configured to call the API function by the application program, and transfer the task identifier of the target task to the operating system, where the task identifier is used for determining, by the operating system, a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and calling the callback function.
Optionally, the application is a native application written based on a non-native language of the operating system.
To sum up, according to the page processing device provided in the embodiment of the present disclosure, the trigger module triggers the target task in the page of the application program, the target task is a task that needs to call an application programming interface API function of the operating system, the call module calls the API function, and transmits a task identifier of the target task to the operating system, so that the operating system can call the callback function according to the task identifier after the API function is executed, and compared with a case where the callback function is called by a function pointer of the callback function, flexibility of software design of developers is improved.
Fig. 5 is a block diagram illustrating a page processing apparatus according to another exemplary embodiment. Referring to fig. 5, the apparatus is based on the block diagram shown in fig. 4, and optionally, the apparatus may further include: the generating module 403 is configured to generate the task identifier when the target task is triggered, and store a corresponding relationship between the task identifier and the callback function.
To sum up, the page processing device provided in the embodiment of the present disclosure generates the task identifier of the task when the generation module triggers the target task, and stores the corresponding relationship between the task identifier and the callback function of the task, thereby implementing establishment of the corresponding relationship between the task identifier corresponding to the task and the callback function corresponding to the task.
Fig. 6 is a block diagram illustrating a page processing apparatus according to still another exemplary embodiment. Referring to fig. 6, the apparatus is based on the block diagram shown in fig. 5, and optionally, the apparatus may further include: a setting module 404 configured to set a callback attribute for the page when the page is initialized.
Accordingly, the generating module 403 includes: the generating submodule 4031 is configured to store the corresponding relationship between the task identifier and the callback function in the callback attribute of the page.
To sum up, the page processing apparatus provided in the embodiment of the present disclosure sets the callback attribute in the page when the setting module initializes the page of the application program, and when the page triggers a task that needs to call an API function of the operating system, the generating module generates the task identifier of the task, and stores the corresponding relationship between the task identifier and the callback function in the callback attribute of the page, thereby implementing management of the corresponding relationship between the task identifier and the callback function in units of pages.
Fig. 7 is a block diagram illustrating a page processing apparatus according to another exemplary embodiment. The apparatus may be implemented as part or all of the terminal by software, hardware or a combination of both. Referring to fig. 7, the apparatus includes: an obtaining module 701 and a callback module 702. Wherein the content of the first and second substances,
an obtaining module 701 configured to obtain a task identifier of a target task delivered by an application program; the target task is triggered in the page of the application program and needs to call an API function of an operating system;
and the callback module 702 is configured to determine a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and call the callback function.
Optionally, the application is a native application written based on a non-native language of the operating system.
To sum up, the page processing apparatus provided in the embodiment of the present disclosure obtains, by the obtaining module, a task identifier of a target task transferred by an application program, where the target task is a task that is triggered in a page of the application program and needs to call an API function of an operating system, and the callback module determines, according to the task identifier, a callback function corresponding to the task identifier after the API function is executed, and calls the callback function, so that the operating system can call the callback function according to the task identifier after the API function is executed, and compared with a case where the callback function is called by a function pointer of the callback function, flexibility of software design of developers is improved
Fig. 8 is a block diagram illustrating a page processing apparatus according to still another exemplary embodiment. Referring to fig. 8, on the basis of the block diagram shown in fig. 7, optionally, the callback module 702 may further include: the determining submodule 7021 is configured to determine, according to the corresponding relationship between the task identifier and the callback function, the callback function corresponding to the task identifier.
Optionally, the corresponding relationship between the task identifier and the callback function is stored in the callback attribute of the page.
To sum up, the page processing device provided in the embodiment of the present disclosure determines, by the determining sub-module, the callback function corresponding to the task identifier according to the task identifier and the corresponding relationship between the task identifier and the callback function, so that the corresponding callback function is determined according to the task identifier.
Fig. 9 is a block diagram illustrating a page processing apparatus according to another exemplary embodiment. The apparatus may be implemented as part or all of the terminal by software, hardware or a combination of both. Referring to fig. 9, the apparatus includes: a trigger module 901, a call module 902, and a callback module 903. Wherein the content of the first and second substances,
a triggering module 901, configured to trigger a target task in a page of an application program, where the target task is a task that needs to call an application programming interface API function of an operating system;
a calling module 902 configured to call the API function and transfer the task identifier of the target task to the operating system;
and the callback module 903 is configured to determine a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and call the callback function.
Optionally, the application is a native application written based on a non-native language of the operating system.
To sum up, the page processing apparatus provided in the embodiment of the present disclosure triggers a target task in a page of an application program through a trigger module, where the target task is a task that needs to call an application programming interface API function of an operating system, and the call module calls the API function and transfers a task identifier of the target task to the operating system, and after the API function is executed by the callback module, the callback module determines a callback function corresponding to the task identifier according to the task identifier and calls the callback function, so that the operating system can call the callback function according to the task identifier after the API function is executed, and compared with a case where the callback function is called through a function pointer of the callback function, flexibility of software design of developers is improved.
Fig. 10 is a block diagram illustrating a page processing apparatus according to still another exemplary embodiment. Referring to fig. 10, on the basis of the block diagram shown in fig. 9, optionally, the apparatus further includes a generating module 904 configured to generate the task identifier when the target task is triggered, and store a corresponding relationship between the task identifier and the callback function; the callback module 903 further includes a determining submodule 9031 configured to determine, according to the task identifier and the corresponding relationship, a callback function corresponding to the task identifier.
To sum up, in the page processing device provided in the embodiment of the present disclosure, when the generation module triggers the target task, the generation module generates the task identifier of the task, stores the corresponding relationship between the task identifier and the callback function of the task, and the determination sub-module determines the callback function corresponding to the task identifier according to the task identifier and the corresponding relationship, thereby implementing establishment of the corresponding relationship between the task identifier corresponding to the task and the callback function corresponding to the task.
Fig. 11 is a block diagram illustrating a page processing apparatus according to still another exemplary embodiment. Referring to fig. 11, the apparatus is based on the block diagram shown in fig. 10, and optionally, the apparatus further includes a setting module 905 configured to, when initializing the page, set a callback attribute for the page;
the generating module 904 comprises: the storage sub-module 9041 is configured to store the corresponding relationship between the task identifier and the callback function in the callback attribute of the page.
To sum up, the page processing apparatus provided in the embodiment of the present disclosure sets the callback attribute in the page when the setting module initializes the page of the application program, and when the page triggers a task that needs to call an API function of the operating system, the generating module generates the task identifier of the task, and stores the corresponding relationship between the task identifier and the callback function in the callback attribute of the page, thereby implementing management of the corresponding relationship between the task identifier and the callback function in units of pages.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 12 is a block diagram illustrating a terminal according to an example embodiment, and as shown in fig. 12, the terminal may include: a processor 1201 and a memory 1202 for storing computer instructions.
Wherein, the processor 1201 runs the computer instruction to execute the following method:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits a task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system completes execution of the API function.
Optionally, the method further includes: and when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function.
Optionally, the method further includes: setting a callback attribute for the page when the application program initializes the page;
storing the corresponding relationship between the task identifier and the callback function, including:
and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
Fig. 13 is a block diagram illustrating a terminal according to another exemplary embodiment, and as shown in fig. 13, the terminal may include: a processor 1301 and a memory 1302 for storing computer instructions.
The processor 1301 runs the computer instruction to execute the following method:
the operating system obtains a task identifier of a target task transmitted by an application program; the target task is triggered in the page of the application program and needs to call an API function of the operating system;
and after the API function is executed, the operating system determines a callback function corresponding to the task identifier according to the task identifier and calls the callback function.
Optionally, the method further includes: and the operating system determines the callback function corresponding to the task identifier according to the task identifier and the corresponding relation between the task identifier and the callback function.
Optionally, the corresponding relationship between the task identifier and the callback function is stored in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
Fig. 14 is a block diagram illustrating a terminal according to still another exemplary embodiment, and as shown in fig. 14, the terminal may include: a processor 1401, and a memory 1402 for storing computer instructions.
Wherein, the processor 1401 runs the computer instructions to execute the following method:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits the task identifier of the target task to the operating system;
and after the operating system executes the API function, determining a callback function corresponding to the task identifier according to the task identifier, and calling the callback function.
Optionally, the method further includes: when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function;
the determining the callback function corresponding to the task identifier according to the task identifier includes: and determining a callback function corresponding to the task identifier according to the task identifier and the corresponding relation.
Optionally, the method further includes: setting a callback attribute for the page when the application program initializes the page;
storing the corresponding relationship between the task identifier and the callback function, including: and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
Fig. 15 is a block diagram illustrating a terminal 800 according to yet another example embodiment. For example, the terminal 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, and the like.
Referring to fig. 15, terminal 800 may include one or more of the following components: 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 terminal 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction 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 operation at the device 800. Examples of such data include instructions for any application or method operating on terminal 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile 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 disks.
Power components 806 provide power to the various components of terminal 800. 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 terminal 800.
The multimedia component 808 includes a screen providing an output interface between the terminal 800 and the user. 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 an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating 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 a focal length and optical zoom capability.
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 terminal 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also 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 keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
Sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for terminal 800. For example, sensor assembly 814 can detect the open/closed state of device 800, the relative positioning of components, such as a display and keypad of terminal 800, sensor assembly 814 can also detect a change in position of terminal 800 or a component of terminal 800, the presence or absence of user contact with terminal 800, orientation or acceleration/deceleration of terminal 800, and a change in temperature of terminal 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object 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 gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
Communication component 816 is configured to facilitate communications between terminal 800 and other devices in a wired or wireless manner. The terminal 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an 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 terminal 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, micro-controllers, microprocessors or other electronic components for performing the methods illustrated in fig. 1, 2 or 3 and described above.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the terminal 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of a terminal, enable the terminal to perform a page processing method, the method comprising:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits a task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system completes execution of the API function.
Optionally, the method further includes: and when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function.
Optionally, the method further includes: setting a callback attribute for the page when the application program initializes the page;
storing the corresponding relationship between the task identifier and the callback function, including:
and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of a terminal, enable the terminal to perform a page processing method, the method comprising:
the operating system obtains a task identifier of a target task transmitted by an application program; the target task is triggered in the page of the application program and needs to call an API function of the operating system;
and after the API function is executed, the operating system determines a callback function corresponding to the task identifier according to the task identifier and calls the callback function.
Optionally, the method further includes: and the operating system determines the callback function corresponding to the task identifier according to the task identifier and the corresponding relation between the task identifier and the callback function.
Optionally, the corresponding relationship between the task identifier and the callback function is stored in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of a terminal, enable the terminal to perform a page processing method, the method comprising:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits the task identifier of the target task to the operating system;
and after the operating system executes the API function, determining a callback function corresponding to the task identifier according to the task identifier, and calling the callback function.
Optionally, the method further includes: when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function;
the determining the callback function corresponding to the task identifier according to the task identifier includes: and determining a callback function corresponding to the task identifier according to the task identifier and the corresponding relation.
Optionally, the method further includes: setting a callback attribute for the page when the application program initializes the page;
storing the corresponding relationship between the task identifier and the callback function, including: and storing the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
Optionally, the application is a native application written based on a non-native language of the operating system.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (24)

1. A page processing method is characterized by comprising the following steps:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits a task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system finishes executing the API function;
and when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function.
2. The method of claim 1, further comprising:
setting a callback attribute for the page by the application program when the page is initialized;
the storing of the corresponding relationship between the task identifier and the callback function includes:
and storing the corresponding relation between the task identification and the callback function in the callback attribute of the page.
3. The method of claim 1 or 2, wherein the application is a native application written based on a non-native language of the operating system.
4. A page processing method is characterized by comprising the following steps:
the operating system obtains a task identifier of a target task transmitted by an application program; the target task is a task which is triggered in the page of the application program and needs to call an API function of the operating system; when the target task is triggered by an application program, the task identifier is generated and the corresponding relation between the task identifier and the callback function is stored;
and after the API function is executed, the operating system determines a callback function corresponding to the task identifier according to the task identifier and calls the callback function.
5. The method of claim 4, further comprising: and the operating system determines the callback function corresponding to the task identifier according to the task identifier and the corresponding relation between the task identifier and the callback function.
6. The method of claim 5, wherein the correspondence between the task identifier and the callback function is stored in a callback attribute of the page.
7. The method of any of claims 4-6, wherein the application is a native application written based on a non-native language of the operating system.
8. A page processing method is characterized by comprising the following steps:
triggering a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the application program calls the API function and transmits the task identifier of the target task to the operating system;
after the API function is executed by the operating system, determining a callback function corresponding to the task identifier according to the task identifier, and calling the callback function;
and when the target task is triggered, generating the task identifier and storing the corresponding relation between the task identifier and the callback function.
9. The method of claim 8, further comprising:
the determining the callback function corresponding to the task identifier according to the task identifier includes: and determining a callback function corresponding to the task identifier according to the task identifier and the corresponding relation.
10. The method of claim 9, further comprising:
setting a callback attribute for the page by the application program when the page is initialized;
the storing of the corresponding relationship between the task identifier and the callback function includes:
and storing the corresponding relation between the task identification and the callback function in the callback attribute of the page.
11. The method of any of claims 8-10, wherein the application is a native application written based on a non-native language of the operating system.
12. A page processing apparatus, comprising:
the trigger module is configured to trigger a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the calling module is configured to call the API function by the application program, transmit a task identifier of the target task to the operating system, and the task identifier is used for determining a callback function corresponding to the task identifier according to the task identifier and calling the callback function after the operating system completes execution of the API function;
the device also comprises a generating module which is configured to generate the task identifier and store the corresponding relation between the task identifier and the callback function when a target task is triggered.
13. The apparatus of claim 12, further comprising a setting module configured to set a callback attribute for the page when the page is initialized;
the generation module comprises a storage submodule configured to store the correspondence between the task identifier and the callback function in the callback attribute of the page.
14. The apparatus of claim 12 or 13, wherein the application is a native application written based on a non-native language of the operating system.
15. A page processing apparatus, comprising:
the obtaining module is configured to obtain a task identifier of a target task transmitted by an application program; the target task is a task which is triggered in the page of the application program and needs to call an API function of an operating system; when the target task is triggered by an application program, the task identifier is generated and the corresponding relation between the task identifier and the callback function is stored;
and the callback module is configured to determine a callback function corresponding to the task identifier according to the task identifier and call the callback function after the API function is executed.
16. The apparatus according to claim 15, wherein the callback module further comprises a determining submodule configured to determine the callback function corresponding to the task identifier according to the task identifier and the correspondence between the task identifier and the callback function.
17. The apparatus of claim 16, wherein the correspondence between the task identifier and the callback function is stored in a callback attribute of the page.
18. The apparatus of any of claims 15-17, wherein the application is a native application written based on a non-native language of the operating system.
19. A page processing apparatus, comprising: the call module comprises a trigger module, a calling module and a callback module;
the trigger module is configured to trigger a target task in a page of an application program, wherein the target task is a task needing to call an Application Programming Interface (API) function of an operating system;
the calling module is configured to call the API function and transmit the task identifier of the target task to the callback module;
the callback module is configured to determine a callback function corresponding to the task identifier according to the task identifier after the API function is executed, and call the callback function;
the device further comprises a generating module, configured to generate the task identifier and store a corresponding relationship between the task identifier and the callback function when the target task is triggered.
20. The apparatus of claim 19,
the callback module further comprises a determining submodule configured to determine a callback function corresponding to the task identifier according to the task identifier and the corresponding relationship.
21. The apparatus of claim 20, further comprising a setting module configured to set a callback attribute for the page when the page is initialized;
the generation module comprises: and the storage sub-module is configured to store the corresponding relation between the task identifier and the callback function in the callback attribute of the page.
22. The apparatus of any of claims 19-21, wherein the application is a native application written based on a non-native language of the operating system.
23. A terminal, comprising:
a processor and a memory for storing computer instructions; the processor executes the computer instructions to perform the method of any of claims 1-11.
24. A computer readable storage medium having computer instructions stored thereon, wherein the computer instructions, when executed by a processor, implement the method of any of claims 1-11.
CN201810753514.2A 2018-07-10 2018-07-10 Page processing method, device, terminal and storage medium Active CN109117144B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810753514.2A CN109117144B (en) 2018-07-10 2018-07-10 Page processing method, device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810753514.2A CN109117144B (en) 2018-07-10 2018-07-10 Page processing method, device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN109117144A CN109117144A (en) 2019-01-01
CN109117144B true CN109117144B (en) 2022-01-18

Family

ID=64862564

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810753514.2A Active CN109117144B (en) 2018-07-10 2018-07-10 Page processing method, device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN109117144B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008668B (en) * 2019-03-21 2023-09-19 北京小米移动软件有限公司 Data processing method, device and storage medium
CN110221813B (en) * 2019-05-27 2023-09-19 北京小米移动软件有限公司 Application data connection establishment method and device, storage medium and electronic equipment
CN110659028B (en) * 2019-09-30 2023-02-28 北京达佳互联信息技术有限公司 Data processing system, method, device, electronic equipment and storage medium
CN113609417A (en) * 2021-07-26 2021-11-05 珠海格力电器股份有限公司 Method, device, equipment and medium for processing mobile terminal page

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222037A (en) * 2010-04-15 2011-10-19 国际商业机器公司 Method and equipment for positioning bottleneck of JAVA program
CN107562540A (en) * 2017-09-05 2018-01-09 武汉斗鱼网络科技有限公司 The method, apparatus and client of call back function are delivered to UI threads

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222037A (en) * 2010-04-15 2011-10-19 国际商业机器公司 Method and equipment for positioning bottleneck of JAVA program
CN107562540A (en) * 2017-09-05 2018-01-09 武汉斗鱼网络科技有限公司 The method, apparatus and client of call back function are delivered to UI threads

Also Published As

Publication number Publication date
CN109117144A (en) 2019-01-01

Similar Documents

Publication Publication Date Title
CN109032606B (en) Native application compiling method and device and terminal
CN107329742B (en) Software development kit calling method and device
CN109117144B (en) Page processing method, device, terminal and storage medium
EP2998899A1 (en) Method and apparatus for running application program
CN107066172B (en) File transmission method and device of mobile terminal
CN110990105B (en) Interface display method and device, electronic equipment and storage medium
CN107423106B (en) Method and apparatus for supporting multi-frame syntax
US9870239B2 (en) Method and device for running application program
CN105808305B (en) Static resource loading method and device
CN110781080B (en) Program debugging method and device and storage medium
CN111240694B (en) Application detection method, application detection device and storage medium
CN107463372B (en) Data-driven page updating method and device
CN110795354A (en) Information processing method, device and storage medium
CN104572230B (en) Script file loading method and device and script file generating method and device
CN110221813B (en) Application data connection establishment method and device, storage medium and electronic equipment
CN109885360B (en) Data processing method, device and storage medium
CN109901886B (en) Page language switching method, system, device and computer readable storage medium
CN108829473B (en) Event response method, device and storage medium
CN107395724B (en) Network request method and device
CN113778687B (en) Memory allocation information processing method and device, electronic equipment and storage medium
CN111596980B (en) Information processing method and device
CN111131000B (en) Information transmission method, device, server and terminal
CN112860625A (en) Data acquisition method, data storage method, device, equipment and storage medium
CN107423060B (en) Animation effect presenting method and device and terminal
CN112102009A (en) Advertisement display method, device, equipment and storage medium

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
GR01 Patent grant