An application calling method and related devices

By introducing intermediate layers and encapsulation components into applications and dynamically relying on different third-party service components, the problem of dynamic loading and switching in the existing technology is solved, and development efficiency and applicability are improved.

CN114385385BActive Publication Date: 2025-07-22SHENZHEN SHANJIAN INTELLIGENT SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111671270.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-07-22
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

The existing technology is unable to dynamically load and switch different third-party service components, resulting in increased development and maintenance costs and reduced efficiency.

Method used

The design of intermediate layer and packaging components is adopted, and the mapping of singleton classes, external interfaces and processing classes is achieved to dynamically rely on different third-party service components. The packaging components can be suitable for different applications, reducing development and maintenance work.

Benefits of technology

It realizes that the application dynamic selection depends on different third-party service components, reduces development and maintenance costs and improves development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385385B_ABST
    Figure CN114385385B_ABST
Patent Text Reader

Abstract

The present invention discloses an application program calling method and related devices. The method includes: when a calling instruction is detected, determining a corresponding singleton class according to the calling instruction; determining an external interface corresponding to the calling instruction in a pre-connected middle layer according to the singleton class; determining a processing class corresponding to the calling instruction in a packaging component connected to the middle layer according to the external interface; and calling a target program corresponding to the calling instruction based on a first dependency relationship corresponding to the external interface and the processing class. In the present invention, the application program can achieve dynamic dependency and removal of calls to third-party application programs, has wide applicability, reduces the time-consuming of application development, and improves efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and particularly to an application program calling method and related devices. Background Art

[0002] With the development of the Internet, more and more applications with various functions have entered people's daily lives. Each application has its main function, and for the same type of product, different focuses may be set during development. Therefore, even for the same type of product, there may be multiple different product projects. For example, a company has instant messaging software A and instant messaging software B. The former focuses on general user chatting, while the latter focuses on the office collaboration scenario. Although the two software have different focuses, there are also similarities in project development. For example, both instant messaging software A and instant messaging software B can log in through a third-party service component.

[0003] Currently, for the third-party services required by product projects, the common method is to encapsulate each third-party service into a component, and then directly call the components encapsulated by different third-party services on the business component. For the above example, both instant messaging software A and instant messaging software B need to connect to each encapsulated third-party service. If originally both instant messaging software A and instant messaging software B were connected to application C and could log in based on application C, and later with iterative updates, it is no longer necessary to log in based on application C, then the call codes of instant messaging software A and instant messaging software B need to be modified. Therefore, this encapsulation method cannot achieve dynamic loading and switching of components encapsulated by different third-party services. In addition, if only different versions of a product are released, different projects also need to be developed and maintained, increasing the development and maintenance costs and reducing efficiency. Summary of the Invention

[0004] The technical problem to be solved by the present invention is the inability to dynamically load and switch different third-party service components. In view of the deficiencies of the prior art, an application program calling method and related devices are provided.

[0005] To solve the above technical problem, the technical solution adopted by the present invention is as follows:

[0006] An application program calling method, the method comprising:

[0007] When a call instruction is detected, according to the call instruction, determine the corresponding singleton class;

[0008] According to the singleton class, determine the external interface corresponding to the call instruction in the pre-connected middle layer;

[0009] Determine the processing class corresponding to the call instruction in the encapsulation component connected to the middle layer according to the external interface;

[0010] Based on the first dependency corresponding to the external interface and the processing class, call the target program corresponding to the call instruction.

[0011] The application program calling method, wherein, before determining the corresponding singleton class according to the call instruction when the call instruction is detected, includes:

[0012] Display the options corresponding to the second dependency according to the preset second dependency;

[0013] When an instruction for the option is detected, generate a call instruction according to the second dependency.

[0014] The application program calling method, wherein, after displaying the options corresponding to the second dependency according to the preset second dependency, further includes:

[0015] Retrieve the encapsulation component corresponding to the second dependency from the pre-connected database according to the second dependency.

[0016] The application program calling method, wherein the method further includes:

[0017] When the target program cannot be called based on the first dependency and the processing class, display a preset error message.

[0018] The application program calling method, wherein, after calling the target program corresponding to the call instruction based on the first dependency corresponding to the external interface and the processing class, further includes:

[0019] Record the processing class that calls the target program;

[0020] Generate a mapping table according to the processing class and the call instruction.

[0021] The application program calling method, wherein the mapping table is a HashMap.

[0022] The application program calling method, wherein, after determining the corresponding singleton class according to the call instruction when the call instruction is detected, further includes:

[0023] When the call instruction is detected, call the target program according to the mapping table.

[0024] An application program calling device, wherein the device includes:

[0025] A first determination module, configured to determine a corresponding singleton class according to the call instruction when the call instruction is detected;

[0026] A second determination module, configured to determine an external interface corresponding to the call instruction in a pre-connected middle layer according to the singleton class;

[0027] A third determination module, configured to determine a processing class corresponding to the call instruction in an encapsulation component connected to the middle layer according to the external interface;

[0028] A call module, configured to call a target program corresponding to the call instruction based on a first dependency relationship corresponding to the external interface and the processing class.

[0029] Wherein, the device further includes a generation module, and the generation module includes:

[0030] A display unit, configured to display options corresponding to the second dependency relationship according to a preset second dependency relationship;

[0031] A generation unit, configured to generate a call instruction according to the second dependency relationship when an instruction for the option is detected.

[0032] Wherein, the generation module further includes a retrieval unit, and the retrieval unit is configured to:

[0033] Retrieve an encapsulation component corresponding to the second dependency relationship from a pre-connected database according to the second dependency relationship.

[0034] Wherein, the device further includes a display module, and the display module is configured to:

[0035] When the target program cannot be called based on the first dependency relationship and the processing class, display a preset error message.

[0036] Wherein, the device further includes a recording module, and the recording module is configured to:

[0037] Record the processing class for calling the target program;

[0038] Generate a mapping table according to the processing class and the call instruction.

[0039] Wherein, the mapping table is a HashMap.

[0040] A computer-readable storage medium storing one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in any of the above application program call methods.

[0041] A terminal device, comprising: a processor, a memory, and a communication bus; a computer-readable program executable by the processor is stored on the memory;

[0042] The communication bus realizes the connection and communication between the processor and the memory;

[0043] When the processor executes the computer-readable program, the steps in the application program calling method described above are implemented.

[0044] Beneficial effects: In this embodiment, the service components of the application program are first packaged to generate a packaged component, and an intermediate layer is set between the packaged component and the used application program. When a third-party application program is called, the program call is realized based on the intermediate layer, so that there is no direct call relationship between the packaged component and the business components of the application program. When the application program to be called needs to be modified, it can be directly modified in the packaged component, or a suitable packaged component can be directly replaced. At the same time, one packaged component can be applicable to different application programs, realizing the dynamic selection of the application program to depend on different third-party packaged components, with wide practicability, reducing the time and effort of development and maintenance, and improving the development efficiency. Description of the Drawings

[0045] Figure 1 It is a flowchart of the application program calling method provided by the present invention.

[0046] Figure 2 It is an overall flowchart of the application program calling method provided by the present invention.

[0047] Figure 3 It is a schematic structural diagram of the application program calling device provided by the present invention.

[0048] Figure 4 It is a schematic structural diagram of the terminal device provided by the present invention. Detailed Embodiments

[0049] The present invention provides an application program calling method. To make the purpose, technical solution and effects of the present invention clearer and more definite, the following further describes the present invention in detail with reference to the accompanying drawings and by way of examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0050] Those skilled in the art of the present technology can understand that, unless specifically stated, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present invention means the presence of the stated features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any unit and all combinations of one or more of the associated listed items.

[0051] Those skilled in the art of the present technology can understand that, unless otherwise defined, all terms used herein (including technical terms and scientific terms) have the same meaning as the general understanding of those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in a general dictionary should be understood to have a meaning consistent with the meaning in the context of the prior art, and will not be interpreted with an idealized or overly formal meaning unless specifically defined as here.

[0052] As Figure 1 shown, the present embodiment provides an application calling method. For the convenience of description, a common intelligent terminal is used as the execution subject for description. Here, the intelligent terminal can be replaced by devices with data processing functions such as a tablet computer or a computer. The application calling method includes the following steps:

[0053] S10. When a call instruction is detected, determine the corresponding singleton class according to the call instruction.

[0054] Specifically, taking the action of logging in as an example, in addition to regular email registration, etc., many applications also support logging in based on a third-party application. In this embodiment, application C is the application to be logged in by the user. When the user uses application C and selects to log in through third-party application A, application C detects a call instruction to call application A for logging in. To distinguish between the two applications, in this embodiment, the application being used by the user is called the using application, and the third-party application to be called is called the calling application.

[0055] At the same time, different call instructions correspond to different services. For example, the calling application corresponding to the call instruction for sharing is a communication and chat application, such as an email. Therefore, different singleton classes are set in advance for the calls of different services.

[0056] Since this example uses the login behavior as an illustration, the service corresponding to the call instruction in this embodiment is the login service, and the singleton class preset for this type of call instruction is LoginUtils.

[0057] S20. Determine the external interface corresponding to the call instruction in the pre-connected middle layer according to the singleton class.

[0058] Specifically, as Figure 2 shown, a middle layer is preset in advance. The middle layer is communicatively connected to the business components. There are several externally developed interfaces inside the middle layer, which are called external interfaces. The middle layer is connected to the third-party application programs through these external interfaces. For each singleton class, the middle layer has a corresponding external interface. Each singleton class implements a certain type of business, and the external interface corresponding to each singleton class is also used to implement this type of business. For example, for the singleton class LoginUtils, the set external interface is the login interface (ILoginProvider).

[0059] After obtaining the singleton class, the external interface corresponding to the call instruction in the middle layer can be determined according to the singleton class.

[0060] Furthermore, the component used in the application program to call the third-party application program is used as the business component. In terms of the processing level, the business component can also be called the business layer. The commonly adopted method is to import the application program as a module into the project. In this embodiment, the business component can be implemented by module_app. As Figure 2 shown, a second dependency relationship of the calling program that the application program can depend on is preset in the project in advance. Taking the application program developed by Android as an example, the project is built using gradle. The project built using gradle includes the build.gradle and settings.gradle files. Among them, the build.gradle file contains the scripts used for project construction, and the settings.gradle file contains necessary settings, such as the dependencies between tasks or projects, that is, the second dependency relationship mentioned above.

[0061] The second dependency relationship represents the calling program based on which the application program provides services. As Figure 2As shown, there is a dependency relationship between the set business layer and the calling program A, while there is no dependency relationship between the business layer and the calling program B. The dependency relationship can be represented by include("LoginA"), the dependent object is the calling program A, and LoginA is the login component of the application A, indicating that the business layer can log in to the service based on the calling program A platform. There is no dependency relationship between the using program and the calling program B, indicating that the using program does not require the calling program B and the project can still run normally. LoginB is the login component of the calling program B. Therefore, the using program can log in based on the calling program A, but cannot log in using the calling program B.

[0062] For example, the calling program A is a commonly used instant messaging program. When logging in to the using program, if it is set that the calling program A can be used for login, then the second dependency relationship of the using program includes a dependency relationship with the calling program A; if it is set to only use the account password for login, then the second dependency relationship of the using program does not include a dependency relationship with the calling program A.

[0063] In order to determine the calling program targeted by the calling instruction subsequently, in this embodiment, before generating the calling instruction, according to the preset second dependency relationship, options corresponding to the second dependency relationship are displayed. When an instruction for the option is detected, a calling instruction is generated according to the second dependency relationship. Therefore, the calling instruction contains information about the calling program to be called. For example, a button for the calling program A is displayed on the login interface, and when a click event for the button is detected, a calling instruction is generated.

[0064] S30. According to the external interface, determine the processing class corresponding to the calling instruction in the pre-connected encapsulation component.

[0065] Specifically, since there are different services in the business layer, such as login service, push service, and sharing service, each specific service needs to call different calling programs. As Figure 2 shown, the service components of different calling programs corresponding to a specific service are packaged into a single component. In this embodiment, the packaged component is called an encapsulation component. A service component refers to a functional component that realizes a service after being called. For example, in the login service, the service component is the login component in the calling program.

[0066] In this embodiment, the encapsulation component includes the service components of two calling programs. One service component is the login component of the calling program A, and the other service component is the login component of the calling program B.

[0067] Meanwhile, the middle layer is connected to the encapsulation component through an external interface, and one external interface is connected to one encapsulation component. For example, it is connected to the encapsulation component that encapsulates multiple login components through ILoginProvider. Through the middle layer, the business component establishes a connection relationship with the encapsulation component. And

[0068] Corresponding to the external interface of the middle layer, classes corresponding to each external interface are provided in the encapsulation component. In this embodiment, such a class is called a processing class. Still taking the behavior of logging in as an example, a login interface is provided in the middle layer, and a processing class LoginProviderImpl corresponding to the login interface is provided in the encapsulation component. In the processing class, the logic for specifically implementing the initialization and invocation of different login components is provided.

[0069] Therefore, according to the external interface, the processing class corresponding to the call instruction in the encapsulation component can be determined. In this embodiment, the processing class corresponding to the call instruction for the target login is LoginProviderImpl.

[0070] Furthermore, in the R & D stage, there are multiple encapsulation components stored in the database, such as the open-source maven repository. When the second dependency relationship is obtained, the encapsulation component corresponding to the second dependency relationship can be retrieved from the database to facilitate subsequent testing of whether the program call is successful.

[0071] S40. Based on the first dependency relationship corresponding to the external interface and the processing class, call the target program corresponding to the call instruction.

[0072] Specifically, in this embodiment, the first dependency relationship refers to the dependency relationship established between the encapsulation component and the middle layer through the external interface. As Figure 2 shown, the encapsulation component includes call program A and call program B. Based on the external interface, call program A and call program B establish a dependency relationship with the middle layer. The call instruction contains the call program information to be called. Based on the call program information, the target program corresponding to the call instruction can be determined. Based on the processing class in the encapsulation component, the target program can be called.

[0073] In this process, one encapsulation component can be adapted to different usage programs. If encapsulation components for different types of call programs have been pre-encapsulated, the usage program can directly connect to the adapted encapsulation component. There is no direct dependency relationship between the usage program and the call program. Even if there is no encapsulation component, the usage program can still run normally. Therefore, the usage program can dynamically select and depend on encapsulation components of different third-party services, with strong applicability, reduced development complexity, reduced development time, and improved development efficiency.

[0074] Further, if the connection between the middle layer and the encapsulation component is successful, the singleton class in the service layer can call the processing class in the encapsulation layer through reflection to wake up the target program. However, when the middle layer or the encapsulation component is not depended on, there may be a phenomenon of reflection failure, that is, the target program cannot be called based on the first dependency relationship and the processing class, and then a preset error message is displayed, which may include "call program not installed", "cannot call", etc.

[0075] After calling the target program, the processing class that calls the target program can be recorded, and a mapping table is generated according to the processing class and the call instruction, that is, the call instruction containing different call program information and the processing class corresponding to the processing logic of different call programs are mapped to obtain the mapping table. The type of the mapping table adopted in this embodiment is HashMap. HashMap is a hash table that stores key-value mappings. HashMap implements the Map interface, stores data according to the HashCode value of the key, has a very fast access speed, allows at most one record to have a null key, and does not support thread synchronization. Subsequently, when in use, the program can directly call according to the HashMap quickly, improving the calling rate.

[0076] As Figure 3 shown, the present invention also provides an application program calling device, and the device includes:

[0077] A first determination module, configured to determine a corresponding singleton class according to the call instruction when detecting the call instruction;

[0078] A second determination module, configured to determine an external interface corresponding to the call instruction in the pre-connected middle layer according to the singleton class;

[0079] A third determination module, configured to determine a processing class corresponding to the call instruction in the encapsulation component connected to the middle layer according to the external interface;

[0080] A calling module, configured to call a target program corresponding to the call instruction based on the first dependency relationship corresponding to the external interface and the processing class.

[0081] Wherein, the device further includes a generation module, and the generation module includes:

[0082] A display unit, configured to display options corresponding to the second dependency relationship according to the preset second dependency relationship;

[0083] A generation unit, configured to generate a call instruction according to the second dependency relationship when detecting an instruction for the option.

[0084] Among them, the generation module further includes a retrieval unit, and the retrieval unit is configured to:

[0085] Retrieve, from a pre-connected database, a packaged component corresponding to the second dependency according to the second dependency.

[0086] Among them, the device further includes a display module, and the display module is configured to:

[0087] When the target program cannot be called based on the first dependency and the processing class, display a preset error message.

[0088] Among them, the device further includes a recording module, and the recording module is configured to:

[0089] Record the processing class that calls the target program;

[0090] Generate a mapping table according to the processing class and the call instruction.

[0091] Among them, the mapping table is a HashMap.

[0092] Based on the above application program calling method, the present invention further provides a terminal device, as Figure 4 shown, which includes at least one processor 20; a display screen 21; and a memory 22, and may further include a communication interface 23 and a bus 24. Among them, the processor 20, the display screen 21, the memory 22, and the communication interface 23 can complete mutual communication through the bus 24. The display screen 21 is set to display a preset user guidance interface in the initial setting mode. The communication interface 23 can transmit information. The processor 20 can call the logical commands in the memory 22 to execute the method in the above embodiments.

[0093] In addition, when the logical commands in the above-mentioned memory 22 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.

[0094] The memory 22, as a computer-readable storage medium, can be set to store software programs and computer-executable programs, such as the program commands or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes functional applications and data processing by running the software programs, commands, or modules stored in the memory 22, that is, implements the methods in the above embodiments.

[0095] The memory 22 may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created according to the use of the terminal device and the like. In addition, the memory 22 may include a high-speed random access memory and may also include a non-volatile memory. For example, various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc that can store program codes may also be a transient computer-readable storage medium.

[0096] In addition, the specific processes of loading and executing multiple commands in the above-mentioned computer-readable storage medium and the terminal device have been described in detail in the above method and will not be repeated here.

[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or equivalently replace some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An application calling method, characterized in that The method includes: When a call instruction is detected, determining a corresponding singleton class according to the call instruction; Determining an external interface corresponding to the call instruction in a pre-connected middle layer according to the singleton class; Determining a processing class corresponding to the call instruction in a packaging component connected to the middle layer according to the external interface; Invoking a target program corresponding to the call instruction based on a first dependency corresponding to the external interface and the processing class; The method further includes: when the target program cannot be invoked based on the first dependency and the processing class, displaying a preset error message.

2. The application program calling method according to claim 1, wherein Before the step of when a call instruction is detected, determining a corresponding singleton class according to the call instruction, it includes: Displaying options corresponding to the second dependency according to a preset second dependency; When an instruction for the option is detected, generating a call instruction according to the second dependency.

3. The application program calling method according to claim 2, wherein After the step of displaying options corresponding to the second dependency according to a preset second dependency, it further includes: Retrieving a packaging component corresponding to the second dependency from a pre-connected database according to the second dependency.

4. The application program calling method according to claim 1, wherein After the step of invoking a target program corresponding to the call instruction based on a first dependency corresponding to the external interface and the processing class, it further includes: Recording the processing class that invokes the target program; Generating a mapping table according to the processing class and the call instruction.

5. The application program calling method according to claim 4, wherein The mapping table is a HashMap.

6. The application program calling method according to claim 2, wherein After the step of when a call instruction is detected, determining a corresponding singleton class according to the call instruction, it further includes: When the call instruction is detected, invoking the target program according to the mapping table.

7. An application calling device, characterized in that, The apparatus includes: A first determination module, configured to determine a corresponding singleton class according to the call instruction when a call instruction is detected; A second determination module, configured to determine an external interface corresponding to the call instruction in a pre-connected middle layer according to the singleton class; A third determination module, configured to determine a processing class corresponding to the call instruction in a packaging component connected to the middle layer according to the external interface; An invocation module, configured to invoke a target program corresponding to the call instruction based on a first dependency corresponding to the external interface and the processing class; The apparatus further includes a display module, and the display module is configured to: when the target program cannot be invoked based on the first dependency and the processing class, display a preset error message.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the application program invocation method according to any one of claims 1 to 6.

9. A terminal device, characterized in that, It includes: A processor, a memory, and a communication bus; The memory stores a computer-readable program executable by the processor; The communication bus realizes connection communication between the processor and the memory; When the processor executes the computer-readable program, it implements the steps in the application program invocation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Visual functional component management method and device

    CN113779467A