Activity component calling processing method and system, computer device and storage medium
By building cross-process connections in the Android system, cross-process calls to Activity components are realized, solving the problem of the narrow scope of calls for UI Activity components, expanding the applicability of Activity components, and improving the logic and operational efficiency of the caller.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 中原银行股份有限公司
- Filing Date
- 2022-10-11
- Publication Date
- 2026-06-05
AI Technical Summary
In the Android system, when calling an Activity component, only the caller with a UI Activity component can achieve the target Activity component call, resulting in a narrow calling scope, which cannot meet the needs of program blocks that do not have a UI Activity component.
By establishing a cross-process connection between the process management component and the proxy Activity component, the caller can communicate with the proxy Activity components in different processes, receive and process intent information, and return the results to the caller. Cross-process communication is achieved using the Binder mechanism.
The scope of the target Activity component's invocation has been expanded, allowing both Activity components with and without a UI to invoke the target Activity component. This reduces the complexity of the caller's code and improves the logic and operational testing efficiency.
Smart Images

Figure CN115543480B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to an Activity component invocation processing method, system, computer device, and storage medium. Background Technology
[0002] In Android apps, starting an Activity and retrieving its returned result is a common scenario. For example, to select a photo from the system photo album, the system photo album activity needs to be started first. After the user selects a photo, the photo album activity returns the selected image. In Android, the target Activity is started and its return result is retrieved using the `Activity.startActivityForResult` method, and the return result is handled in the Activity's `onActivityResult` method. However, the inventors realized that...
[0003] The current operation of launching an Activity and retrieving its return value requires a caller with a UI Activity component. If the caller does not have a UI Activity component, it will be unable to launch the target Activity, resulting in a narrow scope of calls to the target Activity component. Summary of the Invention
[0004] The Activity component call handling method, system, computer device, and storage medium provided in this application are intended to solve the following problems.
[0005] Firstly, this application provides an Activity component invocation processing method, running in a process management component of the terminal, including:
[0006] A communication connection is established with the caller, and a cross-process connection is built with a pre-defined proxy Activity component. The caller is a component displayed on the current page of the terminal, and the cross-process connection enables the caller to access a proxy Activity component that is in a different process from the caller. The caller is a program block that has a UI Activity component or does not have a UI Activity component.
[0007] The system receives intent information input from the caller, sends the intent information to the proxy Activity component through the cross-process connection, and causes the proxy Activity component to call the target Activity component corresponding to the intent information to process the intent information and obtain the return result.
[0008] Receive the return result sent by the proxy Activity component and return the return result to the caller.
[0009] In the above scheme, establishing a cross-process connection with the pre-built proxy Activity component includes:
[0010] Create a service process and generate connection mechanism information corresponding to the service process, and create a connection driver corresponding to the service process;
[0011] The connection mechanism information is sent to the proxy Activity component, and a client process corresponding to the service process is created in the proxy Activity component according to the connection mechanism information;
[0012] A service management process is created in the proxy Activity component, enabling the client process to reference the service process based on the service management process;
[0013] The connection driver is invoked to establish a communication connection between the service process and the client process, and the communication connection is used as the intent information to build a cross-process connection with the proxy Activity component.
[0014] In the above scheme, returning the result to the caller includes:
[0015] Extract the return results from the service process in cross-process connections;
[0016] The returned result is sent to the caller.
[0017] Secondly, this application provides an Activity component invocation processing method, running in a proxy Activity component on the terminal, including:
[0018] Establish a cross-process connection with the process management component and receive intent information sent by the process management component; wherein, the intent information is a request information sent by a caller to the process management component, and the caller is a program block with or without a UI Activity component;
[0019] Identify the target Activity component corresponding to the intent information, and instantiate the target Activity component;
[0020] The target Activity component is invoked to process the intent information to obtain a return result, and the return result sent by the target Activity component is received.
[0021] The return result is sent to the process management component through the cross-process connection, so that the process management component sends the return result to the caller.
[0022] In the above scheme, identifying the target Activity component corresponding to the intent information and instantiating the target Activity component includes:
[0023] Obtain component information from intent information, wherein the component information refers to the number of the target Activity component that the intent information needs to call;
[0024] The target Activity component corresponding to the component information is loaded into a preset idle process, and the target Activity component corresponding to the component information is started. The instantiation of the target Activity component is achieved by loading the target Activity component into the process.
[0025] In the above scheme, the step of calling the target Activity component to process the intent information and obtain a return result, and receiving the return result sent by the target Activity component, includes:
[0026] The target Activity component is invoked to process the intent information through its interaction logic to obtain a return result;
[0027] Receive the return result returned by the target Activity component based on the setting result method in the target Activity component.
[0028] In the above scheme, sending the return result to the process management component through the cross-process connection includes:
[0029] Obtain the return result sent by the target Activity component from the preset component result methods;
[0030] Based on the setting result method in the client process of the cross-process connection, the returned result is sent to the process management component.
[0031] Thirdly, this application provides an Activity component invocation processing system, which runs in a terminal and includes: a caller, a process management component, a proxy Activity component, and at least one target Activity component;
[0032] The caller is connected to the input module of the terminal, and the caller is used to receive intent information sent by the input module; wherein, the caller is a component displayed on the current page of the terminal;
[0033] The process management component is connected to the caller, and there is a cross-process connection between the process management component and the proxy Activity component; wherein, the cross-process connection is used to enable information exchange between the process management component and the proxy Activity component, which are in different processes.
[0034] The process management component is used to receive intent information sent by the caller and send the intent information to the proxy Activity component;
[0035] The proxy Activity component is connected to the at least one target Activity component. The proxy Activity component is used to receive intent information sent by the process management component, identify the target Activity component corresponding to the intent information, and instantiate the target Activity component.
[0036] The proxy Activity component is also used to call the target Activity component to process the intent information to obtain a return result, and to receive the return result sent by the target Activity component corresponding to the intent information, and to send the return result to the process management component through the cross-process connection, so that the process management component sends the return result to the caller;
[0037] The process management component is also used to return the return result sent by the proxy Activity component to the caller.
[0038] Fourthly, this application provides a computer device, including: a processor and a memory communicatively connected to the processor;
[0039] The memory stores computer-executed instructions;
[0040] The processor executes computer execution instructions stored in the memory to implement the Activity component invocation processing method as described above.
[0041] Fifthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the above-described Activity component invocation processing method.
[0042] Sixthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described Activity component invocation processing method.
[0043] The Activity component invocation processing method, system, computer device, and storage medium provided in this application establish a cross-process connection between a process management component and a proxy Activity component. This allows the caller to invoke a target Activity component that is not in the same process as the caller through the proxy Activity component and the cross-process connection, and obtain the return result generated by the target Activity component. This realizes cross-process invocation of Activity components. By using the proxy Activity component, both Activity components with and without interfaces can invoke the target Activity component, expanding the scope of the target Activity component that can be invoked, and thus expanding the applicability of the target Activity component.
[0044] Meanwhile, by using a proxy Activity component to identify the target Activity component corresponding to the intent information, and receiving the return result from the target Activity component after processing the intent information, both the intent information and the return result are fed back to the process management component through the proxy Activity component. This reduces the complexity of the caller's code and improves the caller's logic. It not only ensures that the caller can efficiently obtain data from the target component, but also facilitates maintenance and functional testing of the caller by operations and testing teams. Attached Figure Description
[0045] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0046] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0047] Figure 2 A flowchart of Embodiment 1 of an Activity component invocation processing method provided in this application;
[0048] Figure 3 A flowchart illustrating Embodiment 2 of an Activity component invocation processing method provided in this application;
[0049] Figure 4 A schematic diagram of the program modules of an embodiment 3 of the Activity component call processing system provided by the present invention;
[0050] Figure 5 A communication interaction diagram of program modules in Embodiment 3 of an Activity component call processing system provided by the present invention;
[0051] Figure 6A program module diagram of Embodiment 4 of an Activity component call processing device provided by the present invention;
[0052] Figure 7 A program module diagram of Embodiment 5 of an Activity component call processing device provided by the present invention;
[0053] Figure 8 This is a schematic diagram of the hardware structure of the computer device in the computer device of the present invention.
[0054] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0055] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0056] Please see Figure 1 The specific application scenario of this application is as follows: the caller 11, the process management component 12, the proxy Activity component 13, and at least one target Activity component 14 are installed in the terminal 4. Assuming that the caller 11 is the caller of the first application (e.g., the editing page or background cache of WeChat Moments), and the target Activity component 14 is the cache library of the second application (e.g., pictures or videos on the album page), if the caller is an editing page with the corresponding interface Activity component, it is easy to retrieve the photos from the cache library of the second application. However, if the caller is a background cache without the corresponding interface Activity component, that is, only the photos are retrieved from the cache library of the second application in the background as the returned data, and are not displayed on the interface Activity component, the current Android system will be unable to achieve this requirement due to the defect that it cannot call the target Activity component without an interface Activity component.
[0057] To address this, this application establishes a communication connection between the process management component 12 and the caller, receives intent information (including photo encoding in the album) sent by the caller, and sends the intent information to the proxy Activity component 13. The proxy Activity component 13 then calls the cache library of the second application and loads the cache library into stack 5 to instantiate it. Based on the intent information, it extracts the photo from the instantiated cache library (i.e., returns the data) and sends the product page to the caller via a cross-process connection. This achieves the technical effect of calling the target Activity component and obtaining the photo through the proxy Activity component 13. This allows the caller to not only obtain the photo on the editing page but also cache the photo in a pre-set background cache process without relying on the UI Activity component, thus overcoming the current Android system's inability to call the target Activity component without a UI Activity component.
[0058] The data transmission method provided in this application is intended to solve the above-mentioned technical problems of the prior art.
[0059] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0060] Example 1:
[0061] Please see Figure 2 This application provides an Activity component invocation processing method, which runs in the process management component of the terminal, including:
[0062] S101: Establish a communication connection with the caller and build a cross-process connection with the preset proxy Activity component, wherein the caller is a component displayed on the current page of the terminal, and the cross-process connection is used to enable the caller to access the proxy Activity component in a different process from the caller; wherein the caller is a program block with or without a UI Activity component.
[0063] S102: Receive intent information input by the caller, send the intent information to the proxy Activity component through the cross-process connection, and make the proxy Activity component call the target Activity component corresponding to the intent information to process the intent information and obtain the return result;
[0064] S103: Receive the return result sent by the proxy Activity component and return the return result to the caller.
[0065] This embodiment establishes a cross-process connection with a proxy Activity component and sends the intent information to the proxy Activity component. The proxy Activity component then calls the target Activity component corresponding to the intent information to process the intent information and obtain a return result. This allows the caller to invoke a target Activity component that is not in the same process as the caller through the proxy Activity component and the cross-process connection, and obtain the return result generated by the target Activity component. This achieves cross-process invocation of Activity components. By using the proxy Activity component, both Activity components with and without UI elements can invoke the target Activity component, expanding the scope of the target Activity component that can be invoked, and thus broadening its applicability.
[0066] In a preferred embodiment, establishing a cross-process connection with a pre-defined proxy Activity component includes:
[0067] S11: Create a service process and generate connection mechanism information corresponding to the service process, and create a connection driver corresponding to the service process;
[0068] S12: Send the connection mechanism information to the proxy Activity component, and create a client process corresponding to the service process in the proxy Activity component according to the connection mechanism information;
[0069] S13: Create a service management process in the proxy Activity component so that the client process can reference the service process according to the service management process;
[0070] S14: Invoke the connection driver to establish a communication connection between the service process and the client process, and use the communication connection as the intent information to build a cross-process connection with the proxy Activity component.
[0071] In this embodiment, a service process is created in the process management component and connection mechanism information is generated using AIDL, and a client process is created in the proxy Activity component based on the connection mechanism information using AIDL.
[0072] Since processes in the Android system cannot share memory, this embodiment uses the Binder mechanism to enable data communication between Activity components in different processes within the Android system.
[0073] AIDL stands for Android Interface Definition Language, which is used to define programming interfaces that are recognized by both client processes and service processes, so as to enable communication between the process where the agent Activity component of the client process is located and the process where the process management component of the service process is located.
[0074] Specifically, cross-process connections are Binder communication, which includes:
[0075] Client process: The process that uses the service.
[0076] Server process: The process that provides services.
[0077] ServiceManager process: The role of ServiceManager is to convert the character form of Binder name into a reference to that Binder in the Client, so that the Client can obtain a reference to the Binder entity in the Server through the Binder name.
[0078] Connection driver (Binder driver): Responsible for establishing inter-process Binder communication, passing Binder between processes, managing Binder reference counts, and providing a series of low-level support for data packet transmission and interaction between processes.
[0079] The process management component is used to receive intent information sent by the caller and send the intent information to the proxy Activity component;
[0080] In this embodiment, the process management component starts the proxy Activity component by calling the startActivity() method in Context and sends the intent information to the proxy Activity component.
[0081] Since the proxy Activity component and the process management component reside in different processes, the `startActivity()` method in `Context` enables cross-process operations, allowing the process management component in one process to send a message to the proxy Activity component in another process to start the proxy Activity component. `Context` is a predefined class in the Android system containing methods for starting components. The proxy Activity component is connected to the at least one target Activity component. The proxy Activity component receives intent information sent by the process management component, identifies the target Activity component corresponding to the intent information, and instantiates the target Activity component. The target Activity component and the proxy Activity component communicate through the Binder mechanism pre-built into the Android system. The Binder mechanism enables intra-process communication and cross-process communication between the target Activity component and the proxy Activity component.
[0082] The proxy Activity component is also used to call the target Activity component to process the intent information and obtain a return result, and to receive the return result sent by the target Activity component corresponding to the intent information, and to send the return result to the process management component through the cross-process connection, so that the process management component sends the return result to the caller.
[0083] Because when a caller with an interface Activity component directly calls a target Activity component, the intent information sent by the caller and the return result returned by the target Activity component are often not in the same program block due to the program settings of the Android system itself. This results in a very messy content about intent information and return result in the caller's internal program, which is not conducive to operation and maintenance and testing of the caller's maintenance and functional testing.
[0084] This application identifies the target Activity component corresponding to the intent information through a proxy Activity component, and receives the return result from the target Activity component after processing the intent information through the proxy Activity component. This ensures that both the intent information and the return result are fed back to the process management component one-to-one through the proxy Activity component, and correspond one-to-one within the process management component. Therefore, it reduces the complexity of the caller's code and improves the logical association between intent information and return results. This not only ensures that the caller can efficiently obtain data from the target component, but also facilitates maintenance and functional testing of the caller by operations and testing teams. In a preferred embodiment, returning the return result to the caller includes:
[0085] S21: Extract the return result from the service process in the cross-process connection.
[0086] S22: Send the returned result to the caller.
[0087] In this embodiment, the process management component obtains the return result of the target activity in the onResult method of the binder server (service process). The onResult method is a method that stores the return result sent by the client process to the service process.
[0088] The process management component sends the return result to the caller through a callback for receiving the result. The callback for receiving the result represents the interface of the caller that is invoked when the return result is sent to the caller, enabling the process management component to send the return result to the caller.
[0089] Example 2:
[0090] Please see Figure 3 This application provides an Activity component invocation processing method, which runs in a proxy Activity component on the terminal, including:
[0091] S201: Establish a cross-process connection with the process management component and receive intent information sent by the process management component; wherein, the intent information is a request information sent by a caller to the process management component, and the caller is a program block with or without a UI Activity component;
[0092] S202: Identify the target Activity component corresponding to the intent information, and instantiate the target Activity component;
[0093] S203: Invoke the target Activity component to process the intent information and obtain a return result, and receive the return result sent by the target Activity component;
[0094] S204: The return result is sent to the process management component through the cross-process connection, so that the process management component sends the return result to the caller.
[0095] This embodiment establishes a cross-process connection with the process management component and sends the intent information to the proxy Activity component, so that the proxy Activity component calls the target Activity component corresponding to the intent information to process the intent information and obtain the return result;
[0096] This enables the caller to invoke a target Activity component that is not in the same process as the caller through the proxy Activity component and the cross-process connection, and to obtain the return result generated by the target Activity component. This realizes cross-process invocation of Activity components and expands the range of target Activity components that the caller can invoke.
[0097] Meanwhile, by using a proxy Activity component to identify the target Activity component corresponding to the intent information, and receiving the return result from the target Activity component after processing the intent information, both the intent information and the return result are fed back to the process management component through the proxy Activity component. This reduces the complexity of the caller's code and improves the logical association between the intent information and the return result. It not only ensures that the caller can efficiently obtain data from the target component, but also facilitates maintenance and functional testing of the caller by operations and testing teams.
[0098] In a preferred embodiment, identifying a target Activity component corresponding to the intent information and instantiating the target Activity component includes:
[0099] S31: Obtain component information from intent information, wherein the component information refers to the number of the target Activity component that the intent information needs to call.
[0100] S32: Load the target Activity component corresponding to the component information into a preset idle process, and start the target Activity component corresponding to the component information, wherein the instantiation of the target Activity component is achieved by loading the target Activity component into the process.
[0101] In this embodiment, component information is obtained from the Intent information in the intent information of the proxy Activity component, and the startActivity() method in the proxy Activity component is called to start the target Activity component, launching the target Activity component corresponding to the component information. The startActivity(Intent) method of the Activity component is used to start the target Activity component, and the target Activity component is pushed onto the top of the stack. The Intent parameter describes the target Activity component, and the instantiation of the target Activity component is achieved by loading it into the process.
[0102] In this embodiment, the target Activity component corresponding to the component information can be loaded into an idle process in the process where the proxy Activity component is located, where the idle process is an idle resource in the process where the proxy Activity component is located, so that the target Activity component and the proxy Activity component are in the same process.
[0103] Alternatively, the target Activity component, which corresponds to the component information, can be loaded into an idle process that is different from the process in which the proxy Activity component resides, so that the target Activity component and the proxy Activity component are in different processes;
[0104] The target Activity component and the proxy Activity component communicate via the Binder mechanism pre-built into the Android system. The Binder mechanism enables intra-process communication and cross-process communication between the target Activity component and the proxy Activity component. In a preferred embodiment, the step of calling the target Activity component to process the intent information and obtain a return result, and receiving the return result sent by the target Activity component, includes:
[0105] S41: The target Activity component is invoked to process the intent information through the interaction logic in the target Activity component to obtain a return result;
[0106] S42: Receive the return result returned by the target Activity component according to the setting result method in the target Activity component.
[0107] In this step, the interaction logic includes two words: interaction and logic. Interaction refers to information and operation, how information flows and how operations are performed. Logic is the connection of interactions, combining the interactions involved in a certain way. Therefore, the interaction logic refers to the computer rules predefined in the target Activity component, which determine what kind of operation is performed based on what kind of intent information, and what kind of return result is generated.
[0108] The setResult method in the target Activity component is used to send the data back to its launch page Activity, that is, to return the result to the delegate Activity component.
[0109] In a preferred embodiment, sending the return result to the process management component via the cross-process connection includes:
[0110] S51: Obtain the return result sent by the target Activity component from the preset component result method.
[0111] S52: Based on the setting result method in the client process of the cross-process connection, send the returned result to the process management component.
[0112] In this embodiment, the component result method is the callback function onActivityResult. The principle of the callback function onActivityResult is as follows: ActivityA calls startActivityForResult(intent, requestCode) to start ActivityB; when ActivityB responds to ActivityA, it calls setResult to set the returned result, and then calls finish; finally, the return result of ActivityB is obtained in ActivityA's onActivityResult.
[0113] The setResult method of the binder client (client process) is called to set the return result of the target Activity. Therefore, the return result is sent to the binder server (service process) of the process management component through the setResult method of the client process.
[0114] Example 3:
[0115] Please see Figure 4 and Figure 5This application provides an Activity component invocation processing system 1, which runs in a terminal and includes: a caller 11, a process management component 12, a proxy Activity component 13, and at least one target Activity component 14;
[0116] The caller 11 is connected to the input module of the terminal, and the caller 11 receives intent information sent by the input module; wherein, the caller 11 is a component displayed on the current page of the terminal;
[0117] In this example, the intent information sent by the caller 11 includes intent information and a callback for the received result. The intent information mainly resolves communication between various components of the Android application. The intent describes the action, data involved in the action, and additional data of an operation in the application. Android, based on this intent description, is responsible for finding the corresponding component, passing the intent to the called component, and completing the component call. The input module is the terminal's input device, such as buttons, a touchscreen, or a keyboard. The input module sends the user-triggered button presses or locations to the caller 11 to trigger events at the corresponding buttons or locations.
[0118] The callback of the received result represents the interface of the caller 11 that is invoked when the returned result is sent to the caller 11, so that the process management component 12 can send the returned result to the caller 11, wherein the caller 11 and the process management component 12 are in the same process.
[0119] The process management component 12 is connected to the caller 11, and the process management component 12 has a cross-process connection with the proxy Activity component 13; wherein, the cross-process connection is used to enable information interaction between the process management component 12 and the proxy Activity component 13 which are in different processes.
[0120] In this embodiment, the cross-process connection between the process management component 12 and the proxy Activity component 13 is a communication connection based on the Binder mechanism. Binder is an inter-process communication mechanism used in Android to implement cross-process communication. Connection mechanism information refers to attribute information describing the service process.
[0121] Preferably, the cross-process connection between the process management component 12 and the proxy Activity component 13 includes:
[0122] T11: The service processes and corresponding connection mechanism information in the process management component 12;
[0123] T12: The proxy Activity component 13 has a client process corresponding to the service process created based on the connection mechanism information;
[0124] T13: The proxy Activity component 13 has a service management process, which is used to establish a process connection between the service process and the client process; the process management component 12 has a connection driver, which is used to realize data transfer between the service process and the client process, so that the process connection is converted into the cross-process connection.
[0125] In this embodiment, a service process is created and connection mechanism information is generated in the process management component 12 using AIDL, and a client process is created in the proxy Activity component 13 based on the connection mechanism information using AIDL.
[0126] Since processes in the Android system cannot share memory, this embodiment uses the Binder mechanism to enable data communication between Activity components in different processes within the Android system.
[0127] AIDL stands for Android Interface Definition Language, which is used to define programming interfaces that are recognized by both the client process and the service process, so as to enable communication between the process where the agent Activity component 13 of the client process is located and the process where the process management component 12 of the service process is located.
[0128] Specifically, cross-process connections are Binder communication, which includes:
[0129] Client process: The process that uses the service.
[0130] Server process: The process that provides services.
[0131] ServiceManager process: The role of ServiceManager is to convert the character form of Binder name into a reference to that Binder in the Client, so that the Client can obtain a reference to the Binder entity in the Server through the Binder name.
[0132] Connection driver (Binder driver): Responsible for establishing inter-process Binder communication, passing Binder between processes, managing Binder reference counts, and providing a series of low-level support for data packet transmission and interaction between processes.
[0133] The process management component 12 is used to receive intent information sent by the caller 11 and send the intent information to the proxy Activity component 13;
[0134] In this embodiment, the process management component 12 starts the proxy Activity component 13 by calling the startActivity() method in Context, and sends the intent information to the proxy Activity component 13.
[0135] Since the proxy Activity component 13 and the process management component 12 are in different processes, the cross-process operation of the `startActivity()` method in `Context` enables the process management component 12, which is in one process, to send a message to the proxy Activity component 13, which is in another process, to start the proxy Activity component 13. `Context` is a predefined class in the Android system that contains methods for starting components. The proxy Activity component 13 is connected to the at least one target Activity component 14. The proxy Activity component 13 is used to receive intent information sent by the process management component 12, identify the target Activity component 14 corresponding to the intent information, and instantiate the target Activity component 14. The proxy Activity component 13 is also used to call the target Activity component 14 to process the intent information and obtain a return result, and to receive the return result sent by the target Activity component 14 corresponding to the intent information, and send the return result to the process management component through the cross-process connection, so that the process management component sends the return result to the caller 12.
[0136] Specifically, the proxy Activity component 13 includes:
[0137] T21: The proxy Activity component 13 is used to obtain component information from the Intent information in the intent information, wherein the component information refers to the number of the target Activity component 14 that the intent information needs to call.
[0138] T22: The proxy Activity component 13 is used to load the target Activity component 14 corresponding to the component information into the process where the proxy Activity component 13 is located, and start the target Activity component 14 corresponding to the component information.
[0139] In this embodiment, the component information is obtained from the Intent information in the intent information of the proxy Activity component 13, and the startActivity() method in the proxy Activity component 13 is called to start the target, launching the target Activity component 14 corresponding to the component information. The startActivity(Intent) method of the Activity is used to start the target Activity component 14, and the target Activity component 14 is pushed onto the top of the stack. The Intent parameter describes the target Activity component 14, and the instantiation of the target Activity component 14 is achieved by loading the target Activity component 14 into the process.
[0140] T23: The target Activity component 14 is used to process the intent information through the interaction logic in the target Activity component 14 to obtain a return result, and to send the return result to the proxy Activity component 13 according to the setting result method in the target Activity component 14.
[0141] In this step, the interaction logic includes two words: interaction and logic. Interaction refers to information and operation, how information flows and how operations are performed. Logic refers to the connection of interactions, combining the interactions involved in a certain way. Therefore, the interaction logic refers to the computer rules predefined in the target Activity component 14, which determine what kind of operation is performed based on what kind of intent information, and what kind of return result is generated.
[0142] The setResult method in the target Activity component 14 is used to send the data back to its launch page Activity, that is, to return the returned result to the proxy Activity component 13.
[0143] T24: The proxy Activity component 13 is used to obtain the return result sent by the target Activity component 14 from the component result method in the proxy Activity component 13, and send the return result to the process management component 12 according to the setting result method in the client process of the cross-process connection.
[0144] In this embodiment, the component result method is the callback function onActivityResult. The principle of the callback function onActivityResult is as follows: ActivityA calls startActivityForResult(intent, requestCode) to start ActivityB; when ActivityB responds to ActivityA, it calls setResult to set the returned result, and then calls finish; finally, the return result of ActivityB is obtained in ActivityA's onActivityResult.
[0145] The setResult method of the binder client (client process) is called to set the return result of the target Activity. Therefore, the return result is sent to the binder server (service process) of the process management component 12 through the setResult method of the client process.
[0146] The process management component 12 is also used to return the return result sent by the proxy Activity component 13 to the caller 11.
[0147] In this embodiment, the process management component 12 further includes:
[0148] T31: The process management component 12 is used to extract the return results from the service process in the cross-process connection.
[0149] In this step, the process management component 12 obtains the return result of the target activity in the onResult method of the binder server (service process). The onResult method is a method that stores the return result sent by the client process to the service process.
[0150] T32: The process management component 12 is used to send the returned result to the caller 11.
[0151] In this step, the process management component 12 sends the return result to the caller 11 through the callback of receiving the result. The callback of receiving the result represents the interface of the caller 11 that is called when sending the return result to the caller 11, so that the process management component 12 can send the return result to the caller 11.
[0152] Example 4:
[0153] Please see Figure 6 This application provides an Activity component invocation processing device 2, installed in the process management component of a terminal, comprising:
[0154] The process communication module 21 is used to establish a communication connection with the caller and to build a cross-process connection with a pre-set proxy Activity component, wherein the caller is a component displayed on the current page of the terminal, and the cross-process connection is used to enable the caller to access the proxy Activity component that is in a different process from the caller.
[0155] The cross-process invocation module 22 is used to receive intent information input by the caller, send the intent information to the proxy Activity component through the cross-process connection, and enable the proxy Activity component to call the target Activity component corresponding to the intent information to process the intent information and obtain the return result.
[0156] The result feedback module 23 is used to receive the return result sent by the proxy Activity component and return the return result to the caller.
[0157] Example 5:
[0158] Please see Figure 7 This application provides an Activity component invocation processing device 3, installed in a proxy Activity component on the terminal, comprising:
[0159] The proxy communication module 31 is used to establish a cross-process connection with the process management component and to receive intent information sent by the process management component.
[0160] The target instantiation module 32 is used to identify the target Activity component corresponding to the intent information and instantiate the target Activity component;
[0161] The target invocation module 33 is used to invoke the target Activity component to process the intent information and obtain a return result, and to receive the return result sent by the target Activity component;
[0162] The result return module 34 is used to send the return result to the process management component through the cross-process connection, so that the process management component sends the return result to the caller.
[0163] Example 6:
[0164] To achieve the above objectives, this application also provides a computer device 6, including: a processor and a memory communicatively connected to the processor; the memory stores computer execution instructions;
[0165] The processor executes the computer execution instructions stored in the memory to implement the above-described Activity component invocation processing method. The components of the Activity component invocation processing device can be distributed across different computer devices. Computer device 6 can be a smartphone, tablet, laptop, desktop computer, rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple application servers), etc. The computer device in this embodiment includes, but is not limited to, a memory 61 and a processor 62 that can communicate with each other via a system bus. Figure 8 As shown. It should be noted that, Figure 8 Only computer devices with components are shown; however, it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead. In this embodiment, memory 61 (i.e., readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, memory 61 may be an internal storage unit of the computer device, such as the hard disk or memory of the computer device. In other embodiments, memory 61 may also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device. Of course, memory 61 may also include both internal storage units and external storage devices of the computer device. In this embodiment, memory 61 is typically used to store the operating system and various application software installed on the computer device, such as the program code of the Activity component call processing device in Embodiment 3. In addition, memory 61 can also be used to temporarily store various types of data that have been output or will be output. Processor 62, in some embodiments, can be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor 62 is typically used to control the overall operation of the computer device. In this embodiment, processor 62 is used to run program code stored in memory 61 or process data, for example, to run an Activity component invocation processing device to implement the Activity component invocation processing method described in the above embodiments.
[0166] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. It should be understood that the processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor. The memory may include high-speed RAM, and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk, or optical disk, etc.
[0167] To achieve the above objectives, this application also provides a computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, App application store, etc., which stores computer-executable instructions, and the program implements the corresponding function when executed by processor 62. The computer-readable storage medium of this embodiment is used to store computer-executable instructions that implement the Activity component invocation processing method, and when executed by processor 62, implements the Activity component invocation processing method of the above embodiment.
[0168] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, 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 storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0169] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.
[0170] This application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described Activity component invocation processing method.
[0171] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0172] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0173] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. An Activity component invocation handling method, running in a process management component of a terminal, characterized in that, include: A communication connection is established with the caller, and a cross-process connection is built with a pre-defined proxy Activity component. The caller is a component displayed on the current page of the terminal, and the cross-process connection enables the caller to access a proxy Activity component that is in a different process from the caller. The caller is a program block that has a UI Activity component or does not have a UI Activity component. The system receives intent information input from the caller, sends the intent information to the proxy Activity component through the cross-process connection, and causes the proxy Activity component to call the target Activity component corresponding to the intent information to process the intent information and obtain the return result. Receive the return result sent by the proxy Activity component and return the return result to the caller.
2. The Activity component invocation processing method according to claim 1, characterized in that, The establishment of a cross-process connection with the pre-defined proxy Activity component includes: Create a service process and generate connection mechanism information corresponding to the service process, and create a connection driver corresponding to the service process; The connection mechanism information is sent to the proxy Activity component, and a client process corresponding to the service process is created in the proxy Activity component according to the connection mechanism information; A service management process is created in the proxy Activity component, enabling the client process to reference the service process based on the service management process; The connection driver is invoked to establish a communication connection between the service process and the client process, and the communication connection is used as the intent information to build a cross-process connection with the proxy Activity component.
3. The Activity component invocation processing method according to claim 1, characterized in that, Returning the result to the caller includes: Extract the return results from the service process in cross-process connections; The returned result is sent to the caller.
4. An Activity component invocation processing method, running in a proxy Activity component on the terminal, characterized in that, include: Establish a cross-process connection with the process management component and receive intent information sent by the process management component; wherein, the intent information is a request information sent by a caller to the process management component, and the caller is a program block with or without a UI Activity component; Identify the target Activity component corresponding to the intent information, and instantiate the target Activity component; The target Activity component is invoked to process the intent information to obtain a return result, and the return result sent by the target Activity component is received. The return result is sent to the process management component through the cross-process connection, so that the process management component sends the return result to the caller.
5. The Activity component invocation processing method according to claim 4, characterized in that, The process of identifying the target Activity component corresponding to the intent information and instantiating the target Activity component includes: Obtain component information from intent information, wherein the component information refers to the number of the target Activity component that the intent information needs to call; The target Activity component corresponding to the component information is loaded into a preset idle process, and the target Activity component corresponding to the component information is started. The instantiation of the target Activity component is achieved by loading the target Activity component into the process.
6. The Activity component invocation processing method according to claim 4, characterized in that, The process of invoking the target Activity component to process the intent information and obtain a return result, and receiving the return result sent by the target Activity component, includes: The target Activity component is invoked to process the intent information through its interaction logic to obtain a return result; Receive the return result returned by the target Activity component based on the setting result method in the target Activity component.
7. The Activity component invocation processing method according to claim 4, characterized in that, Sending the returned result to the process management component via the cross-process connection includes: Obtain the return result sent by the target Activity component from the preset component result methods; Based on the setting result method in the client process of the cross-process connection, the returned result is sent to the process management component.
8. An Activity component invocation processing system, running in a terminal, characterized in that, include: The caller, the process management component, the proxy Activity component, and at least one target Activity component; The caller is connected to the input module of the terminal, and the caller is used to receive intent information sent by the input module; wherein, the caller is a component displayed on the current page of the terminal; The process management component is connected to the caller, and there is a cross-process connection between the process management component and the proxy Activity component; wherein, the cross-process connection is used to enable information exchange between the process management component and the proxy Activity component, which are in different processes. The process management component is used to receive intent information sent by the caller and send the intent information to the proxy Activity component; The proxy Activity component is connected to the at least one target Activity component. The proxy Activity component is used to receive intent information sent by the process management component, identify the target Activity component corresponding to the intent information, and instantiate the target Activity component. The proxy Activity component is also used to call the target Activity component to process the intent information to obtain a return result, and to receive the return result sent by the target Activity component corresponding to the intent information, and to send the return result to the process management component through the cross-process connection, so that the process management component sends the return result to the caller; The process management component is also used to return the return result sent by the proxy Activity component to the caller.
9. A computer device, characterized in that, include: A processor and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the Activity component invocation processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the Activity component invocation processing method as described in any one of claims 1 to 7.