Data interaction method and device for Flutter application, equipment and medium
By creating foreground services and timing tasks, the problem of disconnection of communications after Flutter application exits is solved, and data can be interacted with the second electronic device after exiting or returning to the previous level is achieved, extending the application's life cycle.
Patent Information
- Application Number
- CN202510244672.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-07-04
AI Technical Summary
After the Flutter application exits or returns to the previous level, the communication connection between the electronic device and other devices is disconnected, resulting in data interaction being unable to be realized.
Create foreground services and timing tasks. The target Flutter application establishes a communication connection with the second electronic device when the foreground is running, and detects the timing time of the timing task when exiting or returning to the previous level. When the timing time arrives, it executes the timing task, including loading dependencies to establish a communication connection and releasing the dependencies after interacting with data.
Extends the life cycle of the Flutter application, ensuring that data can still be interacted with the second electronic device after exiting or returning to the previous level, reducing the possibility that the foreground service will be destroyed by the operating system.
Smart Images

Figure CN120256044A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly, to a data interaction method, apparatus, device, and medium for a Flutter application. Background Art
[0002] For a Flutter application installed on an electronic device, when the Flutter application returns to the previous level or exits, its running environment will be destroyed by the operating system (such as Android). On this basis, if the Flutter application installed on the electronic device involves communication connection with other devices, after returning to the previous level or exiting, the communication connection between the electronic device and other devices will also be disconnected. This results in the inability to perform data interaction between other devices and the electronic device to implement the functions of the Flutter application. For example, when the other device is a bracelet for collecting the user's body index data, the electronic device is the user's mobile phone, and the Flutter application is to synchronize the user's body index data from the bracelet, the bracelet cannot synchronize the user's body index data to the user's mobile phone. Summary of the Invention
[0003] An object of this application is to provide a new technical solution for data interaction of a Flutter application.
[0004] According to the first aspect of this application, there is provided a data interaction method for a Flutter application, which is applied to a first electronic device and includes:
[0005] For a target Flutter application on the first electronic device, create a foreground service and a timed task, and establish a first communication connection with a second electronic device when the target Flutter application is running in the foreground;
[0006] When the target Flutter application exits or returns to the previous level, detect whether the timed duration of the timed task has reached;
[0007] When the timed duration of the timed task has reached, execute the timed task;
[0008] Wherein, the timed task includes: loading the dependencies of the target Flutter application to establish the first communication connection and interacting with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed.
[0009] Optionally, the detecting whether the timed duration of the timed task has reached includes:
[0010] When the power of the first electronic device is greater than a preset power, detect whether the timing duration of the timing task has reached;
[0011] And / or, the first electronic device interacts with the second electronic device to obtain target data, and is used to upload the target data to a third electronic device. When a second communication connection is established with the third electronic device, detect whether the timing duration of the timing task has reached.
[0012] Optionally, loading the dependencies of the target Flutter application includes:
[0013] Load the dependencies of the target Flutter application according to the lazy loading mechanism.
[0014] Optionally, the method further includes:
[0015] When the establishment of the first communication connection fails continuously for a preset number of times, reload the dependencies after a preset duration, and the preset duration is less than the timing duration.
[0016] Optionally, the first electronic device interacts with the second electronic device to obtain target data, and is used to upload the target data to a third electronic device. After loading the dependencies of the target Flutter application, the method further includes:
[0017] When the first electronic device and the third electronic device do not establish a second communication connection, store the target data in a local database;
[0018] When the second communication connection is established, upload the target data in the local database to the third electronic device.
[0019] Optionally, the first electronic device obtains original data from the second electronic device by interacting with the second electronic device. After loading the dependencies of the target Flutter application, the method further includes:
[0020] Process the original data in batches to obtain target data.
[0021] Optionally, the first electronic device is used to upload the target data to a third electronic device. After processing the original data in batches to obtain target data, the method further includes:
[0022] Upload the target data to the third electronic device in batches.
[0023] According to the second aspect of the present application, there is provided a data interaction device for a Flutter application, which is applied to a first electronic device and includes:
[0024] A creation module, configured to create a foreground service and a scheduled task for a target Flutter application on a first electronic device, where the target Flutter application establishes a first communication connection with a second electronic device when running in the foreground;
[0025] A detection module, configured to detect whether the scheduled duration of the scheduled task has reached when the target Flutter application exits or returns to the previous level;
[0026] An execution module, configured to execute the scheduled task when the scheduled duration of the scheduled task has reached;
[0027] Wherein, the scheduled task includes: loading dependencies of the target Flutter application to establish the first communication connection and interacting with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed.
[0028] According to a third aspect of the present application, a first electronic device is provided, and the first electronic device includes the device described in the second aspect;
[0029] Alternatively, the first electronic device includes a memory and a processor, the memory is configured to store computer instructions, and the processor is configured to call the computer instructions from the memory to execute the method described in any one of the first aspect.
[0030] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and the computer program, when executed by a processor, implements the method described in any one of the first aspect.
[0031] The present application provides a data interaction method for a Flutter application, which is applied to a first electronic device and includes: creating a foreground service and a timing task for a target Flutter application on the first electronic device, and establishing a first communication connection with a second electronic device when the target Flutter application is running in the foreground; detecting whether the timing duration of the timing task has reached when the target Flutter application exits or returns to the previous level; executing the timing task when the timing duration of the timing task has reached; wherein, the timing task includes: loading dependencies of the target Flutter application to establish the first communication connection and interacting with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed. Based on this method, when the target Flutter application exits or returns to the previous level, the foreground service of the target Flutter application can still run. Further, through the timing task, the first electronic device interacts with the second electronic device, while reducing the possibility that the foreground service of the target Flutter application is destroyed by the operating system, thereby extending the life cycle of the target Flutter application. Wherein, when the second electronic device is a bracelet and the target Flutter application is a Flutter application for synchronizing the user's body index data from the bracelet, when the first electronic device interacts with the second electronic device based on the first communication connection, the user's body index data can be obtained from the second electronic device.
[0032] Other features and advantages of the present application will become clear through the following detailed description of exemplary embodiments of the present application with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings incorporated in the specification and constituting a part of the specification illustrate embodiments of the present application and, together with the description, are used to explain the principles of the present application.
[0034] Figure 1 is a block diagram of the hardware configuration of a first electronic device for implementing a data interaction method of a Flutter application according to an embodiment of the present application Figure 1 ;
[0035] Figure 2 is a schematic flowchart of a method for implementing data interaction of a Flutter application according to an embodiment of the present application;
[0036] Figure 3 is a schematic structural diagram of a device for implementing a data interaction method of a Flutter application according to an embodiment of the present application;
[0037] Figure 4It is a block diagram of the hardware configuration of a first electronic device for implementing a data interaction method of a Flutter application according to an embodiment of the present application Figure 2 . Detailed implementation manners
[0038] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that: unless otherwise specifically stated, the relative arrangements, numerical expressions, and numerical values of the components and steps set forth in these embodiments do not limit the scope of the present application
[0039] The following description of at least one exemplary embodiment is merely illustrative in nature and in no way serves as a limitation on the present application, its application, or use
[0040] Techniques, methods, and devices known to those of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, such techniques, methods, and devices should be considered as part of the specification
[0041] In all the examples shown and discussed here, any specific value should be construed as merely exemplary and not as a limitation. Therefore, other examples of the exemplary embodiments may have different values
[0042] It should be noted that: like reference numerals and letters denote like items in the following drawings, and thus, once an item is defined in one drawing, it need not be further discussed in subsequent drawings
[0043] Figure 1 It is a block diagram of the hardware configuration of a first electronic device for implementing a data interaction method of a Flutter application according to an embodiment of the present application Figure 1 .
[0044] The first electronic device 1000 may be a terminal or a server. Further, the terminal may be a smart phone, a portable computer, a tablet computer, a handheld computer, etc. The server may be a cloud server, etc
[0045] The first electronic device 1000 may include a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500, an input device 1600, a speaker 1700, a microphone 1800, and so on. Among them, the processor 1100 may be a central processing unit CPU, a microcontroller unit MCU, etc. The memory 1200 includes, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The interface device 1300 includes, for example, a USB interface, a headphone interface, etc. The communication device 1400 can perform wired or wireless communication, for example. The display device 1500 is, for example, a liquid crystal display screen, a touch display screen, etc. The input device 1600 may include, for example, a touch screen, a keyboard, etc. The user can input / output voice information through the speaker 1700 and the microphone 1800.
[0046] Although multiple devices are shown for the first electronic device 1000 in Figure 1 , this application may only relate to some of the devices. For example, the first electronic device 1000 only relates to the memory 1200 and the processor 1100.
[0047] In the embodiments applied to this application, the memory 1200 of the first electronic device 1000 is used to store instructions for controlling the processor 1100 to execute the data interaction method of the Flutter application provided in the embodiments of this application.
[0048] In the above description, those skilled in the art can design instructions according to the solutions disclosed in this application. How the instructions control the processor to operate is well known in the art, so it will not be described in detail here.
[0049] This application also provides a data interaction method for a Flutter application, which is applied to the first electronic device as shown in Figure 1 and includes the following steps S2100 to step S2300 as shown in Figure 2 .
[0050] Step S2100: Create a foreground service and a scheduled task for the target Flutter application on the first electronic device.
[0051] Among them, when the target Flutter application runs in the foreground, it establishes a first communication connection with the second electronic device.
[0052] In this embodiment, the second electronic device may be a smart wearable device, such as a bracelet that can collect user body index data. Of course, the second electronic device may also be other electronic devices that can perform data interaction with the first electronic device.
[0053] The target Flutter application is specifically a Flutter application that requires the first electronic device to establish a first communication connection with the second electronic device when running in the foreground of the first electronic device. That is, the target Flutter application establishes a first communication connection with the second electronic device when running in the foreground. Among them, the first communication connection can be exemplarily a Bluetooth connection. Of course, it can also be other communication connections, which will not be elaborated here.
[0054] Since the target Flutter application is essentially still a Flutter application, when the target Flutter application exits or returns to the previous level during operation, the first communication connection between the first electronic device and the second electronic device is disconnected, and the first electronic device and the second electronic device cannot interact data. To avoid this problem, a foreground service and a timed task are created for the target Flutter application.
[0055] When a foreground service is created for the target Flutter application, if the target Flutter application exits or returns to the previous level, the foreground service of the target Flutter application still continues to run.
[0056] Although the priority of the created foreground service is higher than that of other applications in the first electronic device and the possibility of being destroyed by the operating system's running environment is low, there is still a possibility of being destroyed by the operating system in the case of excessive memory occupancy or low battery power of the first electronic device. To solve this problem, a timed task is continued to be created for the target Flutter application. Among them, the description of the timed task is specifically referred to the following steps S2200 to S2300.
[0057] It should be noted that in order to be able to create a foreground service, the permissions of the operating system need to be declared in advance.
[0058] In an embodiment of the present application, communication can be carried out with the native JVM environment through MethodChannel to implement the creation of the foreground service and the timed task of the target Flutter application in the above step S2100.
[0059] Step S2200, when the target Flutter application exits or returns to the previous level, detect whether the timing duration of the timed task has reached.
[0060] In this embodiment, the timing duration is the duration corresponding to the period during which the first electronic device and the second electronic device need to interact data. The timing duration can be set according to experience. In one example, the timing duration is 30 minutes.
[0061] When the target Flutter application exits or returns to the previous level, the foreground service of the target Flutter application continues to run. At this time, the first electronic device and the second electronic device still establish a first communication connection, but there is a possibility that the foreground service will have its running environment destroyed by the operating system. To reduce the possibility that the foreground service will have its running environment destroyed by the operating system. At this time, it is detected whether the scheduled duration of the scheduled task has been reached.
[0062] In one example, if the scheduled duration of the scheduled task is 30 minutes, when the cumulative duration reaches 30 minutes, it is determined that the scheduled duration of the scheduled task has been reached. Conversely, if the cumulative duration has not reached 30 minutes, it is determined that the scheduled duration of the scheduled task has not been reached.
[0063] Step S2300, when the scheduled duration of the scheduled task has been reached, execute the scheduled task.
[0064] Among them, the scheduled task includes: loading the dependencies of the target Flutter application to establish a first communication connection and interacting with the second electronic device based on the first communication connection, and when the data interaction is completed, releasing the dependencies to disconnect the first communication connection.
[0065] In this embodiment, when the scheduled duration of the scheduled task has been reached, the scheduled task is executed. At this time, the first electronic device first performs the operation of loading the dependencies of the target Flutter application. It can be understood that only the dependencies of the target Flutter application are loaded, so as to avoid loading too many resources at one time.
[0066] Among them, the dependencies of the target Flutter application are external libraries or modules on which the target Flutter application depends, and the external libraries or modules on which the target Flutter application depends provide various functions and services required by the Flutter application. In one example, the dependencies are a database and a network library, etc.
[0067] Based on the above, after performing the operation of loading the dependencies of the target Flutter application, the first electronic device and the second electronic device establish a first communication connection. Further, the first electronic device interacts with the second electronic device based on the first communication connection. In one example, when the second electronic device is a smart bracelet and the target Flutter application is a Flutter application for synchronizing the user's body index data from the smart bracelet, when the first electronic device interacts with the second electronic device based on the first communication connection, it can obtain the user's body index data from the second electronic device.
[0068] Further, when the data interaction with the second electronic device is completed based on the first communication connection, for example, when the complete user body index data is obtained from the second electronic device, the first electronic device continues to perform the operation of releasing dependencies. At this time, the first communication connection between the first electronic device and the second electronic device is disconnected. On this basis, resources such as the module corresponding to the first communication connection in the first electronic device are released, and there is only a running shell in the memory of the target Flutter application, that is, the memory occupied by the target Flutter application is greatly reduced. This can further reduce the possibility that the operating system destroys the foreground service of the target Flutter application, thereby further extending the life cycle of the target Flutter application.
[0069] Based on the above content, when the scheduled duration of the scheduled task has not arrived, the target Flutter application is in the state of having released dependencies. At this time, the target Flutter application maintains the state of having only a running shell in the above-mentioned memory.
[0070] This application provides a data interaction method for a Flutter application, which is applied to a first electronic device and includes: for a target Flutter application on the first electronic device, creating a foreground service and a scheduled task, and establishing a first communication connection with a second electronic device when the target Flutter application is running in the foreground; when the target Flutter application exits or returns to the previous level, detecting whether the scheduled duration of the scheduled task has arrived; when the scheduled duration of the scheduled task has arrived, executing the scheduled task; where the scheduled task includes: loading the dependencies of the target Flutter application to establish a first communication connection and interacting data with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed. Based on this method, when the target Flutter application exits or returns to the previous level, the foreground service of the target Flutter application can still run. Further, through the scheduled task, the first electronic device interacts data with the second electronic device, and at the same time reduces the possibility that the foreground service of the target Flutter application is destroyed by the operating system, thereby extending the life cycle of the target Flutter application. Among them, when the second electronic device is a smart bracelet and the target Flutter application is a Flutter application for synchronizing the user's body index data from the smart bracelet, when the first electronic device interacts data with the second electronic device based on the first communication connection, the user body index data can be obtained from the second electronic device.
[0071] In an embodiment of this application, the detection of whether the scheduled duration of the scheduled task in step S2200 has arrived can be specifically implemented by the following step S2210 and / or step S2220.
[0072] Step S2210, when the power of the first electronic device is greater than the preset power, detect whether the timing duration of the timing task has reached.
[0073] In this embodiment, the preset power is the power at which the first electronic device recovers resources due to low power. When the power of the first electronic device is less than or equal to the preset power, there is a high probability that the foreground service of the target Flutter application will have its running environment destroyed. At this time, it is generally meaningless to detect whether the timing duration of the timing task has reached. Therefore, only when the power of the first electronic device is greater than the preset power, detect whether the timing duration of the timing task has reached.
[0074] Step S2220, the first electronic device interacts with the second electronic device to obtain target data, and is used to upload the target data to the third device. When a second communication connection is established with the third electronic device, detect that the timing duration of the timing task has reached.
[0075] In this embodiment, the target data may be the original data obtained by the first electronic device from the second electronic device. The target data may also be the data obtained after the first electronic device processes the original data obtained from the second electronic device. The second communication connection is usually an Internet network connection. The third electronic device is usually a cloud server.
[0076] After the first electronic device obtains the target data, it needs to upload the target data to the third electronic device based on the second communication connection with the third electronic device. If the second communication connection between the first electronic device and the third electronic device is disconnected, even if the first electronic device obtains the target data, it cannot upload the target data to the third electronic device. Therefore, it is meaningless to detect whether the timing duration of the timing task has reached. Based on this, only when a second communication connection is established between the first electronic device and the third electronic device, detect whether the timing duration of the timing task has reached.
[0077] In an embodiment of the present application, the step of loading the dependencies of the target Flutter application during the execution of the timing task can be specifically implemented by the following step S2310.
[0078] Step S2310, load the dependencies of the target Flutter application according to the lazy loading mechanism.
[0079] In this embodiment, the lazy loading mechanism, also known as deferred loading or on-demand loading, is a technical means to optimize resource loading. The lazy loading mechanism allows resources on the application to be initialized and loaded only when needed, rather than initializing and loading all resources when the application is first loaded. On this basis, controlling the timing task to load dependencies in accordance with the lazy loading mechanism can further reduce the consumption of resources such as memory, thereby further reducing the probability that the running environment of the foreground service of the target Flutter application is destroyed, so as to extend the life cycle of the target Flutter application.
[0080] In one embodiment of the present application, the data interaction method of the Flutter application provided by the present application further includes the following step S2400 after the above step S2300.
[0081] Step S2400, in the case where the establishment of the first communication connection fails continuously for a preset number of times, reload the dependencies after a preset duration, and the preset duration is less than the timing duration.
[0082] In this embodiment, the preset number of times can be set according to experience or requirements. In one example, the preset number of times is 3 times.
[0083] In order to ensure the stability of the first communication connection and avoid invalid establishment of the first communication connection, in the case where the establishment of the first communication connection with the second electronic device fails continuously for a preset number of times, the restoration of the first communication connection with the second electronic device is stopped until the preset duration is reached. After the preset duration is reached, the dependencies are reloaded so that the first communication connection is re-established between the first electronic device and the second electronic device, and then data is interacted with the second electronic device based on the first communication connection.
[0084] In one embodiment of the present application, the first electronic device and the second electronic device interact data to obtain target data, and are used to upload the target data to the third electronic device. On this basis, the data interaction method of the Flutter application provided by the present application further includes the following step S2320 and step S2330 after the step of loading the dependencies of the target Flutter application during the execution of the timing task.
[0085] Step S2320, in the case where the second communication connection is not established between the first electronic device and the third electronic device, store the target data in the local database.
[0086] In this embodiment, the first electronic device needs to upload target data to the third electronic device. However, a second communication connection is not established between the first electronic device and the third electronic device, which causes the first electronic device to be unable to successfully upload the target data to the third electronic device. At this time, the first electronic device first stores the target data in the local data to enable caching of the target data even when the second communication connection is not established between the first electronic device and the third electronic device.
[0087] Step S2330: When the second communication connection is established, upload the target data in the local database to the third electronic device.
[0088] In this embodiment, when the second communication connection between the first electronic device and the third electronic device is restored, the target data in the local database is uploaded to the third electronic device, so that the target data can be successfully uploaded to the third electronic device.
[0089] In an embodiment of the present application, the first electronic device obtains original data from the second electronic device by interacting with the second electronic device. On this basis, after the step of loading the dependencies of the target Flutter application in the process of executing the timing task in the data interaction method of the Flutter application provided in the present application, the following step S2340 is further included.
[0090] Step S2340: Process the original data in batches to obtain target data.
[0091] In this embodiment, the target data is the data obtained after the first electronic device processes the original data obtained from the second electronic device.
[0092] In this embodiment, by processing the original data in batches, the instantaneous occupancy of the memory can be reduced. In this way, the probability that the running environment of the foreground service of the target Flutter application is destroyed can be further reduced, thereby extending the life cycle of the target Flutter application.
[0093] In an embodiment of the present application, on the basis of the above step S2340, the first electronic device is used to upload the target data to the third electronic device. Based on this, after the above step S2340 in the data interaction method of the Flutter application provided in the present application, the following step S2350 is further included.
[0094] Step S2350: Upload the target data to the third electronic device in batches.
[0095] In this embodiment, by uploading the target data to the third electronic device in batches, the instantaneous occupation of the memory can be reduced. In this way, the probability that the running environment of the target Flutter application is destroyed can be further reduced, thereby extending the life cycle of the target Flutter application.
[0096] This application also provides a data interaction device 300 for a Flutter application, which is applied to the first electronic device, such as Figure 3 shown, including:
[0097] A creation module 310, configured to create a foreground service and a timing task for a target Flutter application on the first electronic device, and establish a first communication connection with the second electronic device when the target Flutter application is running in the foreground;
[0098] A detection module 320, configured to detect whether the timing duration of the timing task has reached when the target Flutter application exits or returns to the previous level;
[0099] An execution module 330, configured to execute the timing task when the timing duration of the timing task reaches;
[0100] Wherein, the timing task includes: loading dependencies of the target Flutter application to establish the first communication connection and interacting data with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed.
[0101] In an embodiment of this application, the detection module 320 is specifically configured to:
[0102] When the power of the first electronic device is greater than a preset power, detect whether the timing duration of the timing task has reached;
[0103] And / or, the first electronic device interacts with the second electronic device to obtain target data, and is used to upload the target data to the third electronic device, and detect whether the timing duration of the timing task has reached when establishing a second communication connection with the third electronic device.
[0104] In an embodiment of this application, the execution module 330 is specifically configured to: load the dependencies of the target Flutter application according to the lazy loading mechanism.
[0105] In an embodiment of this application, the execution module 330 is further configured to: when the establishment of the first communication connection fails continuously for a preset number of times, reload the dependencies after a preset duration, and the preset duration is less than the timing duration.
[0106] In an embodiment of the present application, the first electronic device interacts with the second electronic device to obtain target data, and is used to upload the target data to a third electronic device. On this basis, the data interaction device 300 of the Flutter application provided by the present application further includes:
[0107] An upload module, configured to store the target data in a local database when the second communication connection is not established between the first electronic device and the third electronic device;
[0108] When the second communication connection is established, upload the target data in the local database to the third electronic device.
[0109] In an embodiment of the present application, the data interaction device 300 of the Flutter application provided by the present application further includes:
[0110] A processing module, configured to batch process the original data to obtain target data.
[0111] In an embodiment of the present application, the upload module is further configured to batch upload the target data to the third electronic device.
[0112] The present application also provides a first electronic device, which includes any one of the data interaction devices 300 of the Flutter application provided in the above device embodiment.
[0113] Or, as Figure 4 shown, the first electronic device 400 includes a memory 410 and a processor 420. The memory 410 is used to store computer instructions, and the processor 420 is used to call the computer instructions from the memory 410 to execute any one of the data interaction methods of the Flutter application provided in the above method embodiment.
[0114] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements any one of the data interaction methods of the Flutter application provided in the above method embodiment.
[0115] The present application may be a system, a method, and / or a computer program product. The computer program product may include a computer-readable storage medium, on which computer-readable program instructions are loaded for causing a processor to implement various aspects of the present application.
[0116] A computer-readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example—but not limited to—an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punched card or raised structures in grooves having instructions stored thereon, and any suitable combination of the foregoing. The computer-readable storage medium used herein is not construed as being a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., an optical pulse through an optical fiber cable), or an electrical signal transmitted through a wire.
[0117] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to respective computing / processing devices, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include a copper transmission cable, an optical fiber transmission, a wireless transmission, a router, a firewall, a switch, a gateway computer, and / or an edge server. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing / processing device.
[0118] The computer program instructions for performing the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine - related instructions, microcode, firmware instructions, state - setting data, or source code or object code written in any combination of one or more programming languages, including object - oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer - readable program instructions may be executed entirely on the user's computer, partially on the user's computer, executed as a stand - alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via an Internet service provider through the Internet). In some embodiments, by using the state information of the computer - readable program instructions to customize an electronic circuit, such as a programmable logic circuit, a field - programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit can execute the computer - readable program instructions to implement various aspects of this application.
[0119] Aspects of the present application are described herein with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer - readable program instructions.
[0120] These computer - readable program instructions can be provided to a processor of a general - purpose computer, a special - purpose computer, or other programmable data - processing apparatus to produce a machine such that, when the instructions are executed by the processor of the computer or other programmable data - processing apparatus, a device is produced that implements the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer - readable program instructions can also be stored in a computer - readable storage medium, and these instructions cause a computer, a programmable data - processing apparatus, and / or other devices to work in a particular manner. Thus, the computer - readable medium storing the instructions includes a manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0121] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device, causing a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process such that the instructions executed on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in one or more boxes of the flowchart and / or block diagram.
[0122] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two consecutive blocks may in fact be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block of the block diagrams and / or flowchart, and combinations of blocks in the block diagrams and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or acts, or by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that implementation by hardware, implementation by software, and implementation by a combination of software and hardware are equivalent.
[0123] The embodiments of the present application have been described above. The above description is exemplary and not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art in the technical field without departing from the scope and spirit of the described embodiments. The selection of the terms used herein is intended to best explain the principles of the embodiments, the practical application, or the technical improvement of the technology in the market, or to enable other ordinary skilled persons in the technical field to understand the embodiments disclosed herein. The scope of the present application is defined by the appended claims.
Claims
1. A data interaction method for a Flutter application, characterized in that, Applied to a first electronic device, including: For a target Flutter application on the first electronic device, create a foreground service and a timing task, and establish a first communication connection with a second electronic device when the target Flutter application is running in the foreground; When the target Flutter application exits or returns to the previous level, detect whether the timing duration of the timing task has reached; When the timing duration of the timing task reaches, execute the timing task; Wherein, the timing task includes: loading dependencies of the target Flutter application to establish the first communication connection and interacting with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed.
2. The method according to claim 1, wherein The detecting whether the timing duration of the timing task has reached includes: When the battery power of the first electronic device is greater than a preset battery power, detect whether the timing duration of the timing task has reached; And / or, the first electronic device interacts with the second electronic device to obtain target data and is used to upload the target data to a third electronic device. When a second communication connection is established with the third electronic device, detect whether the timing duration of the timing task has reached.
3. The method according to claim 1, wherein The loading the dependencies of the target Flutter application includes: Loading the dependencies of the target Flutter application according to the lazy loading mechanism.
4. The method according to claim 1, wherein The method further includes: When the establishment of the first communication connection fails continuously for a preset number of times, reload the dependencies after a preset duration, and the preset duration is less than the timing duration.
5. The method according to claim 1, characterized in that, The first electronic device interacts with the second electronic device to obtain target data and is used to upload the target data to a third electronic device. After loading the dependencies of the target Flutter application, the method further includes: When the first electronic device and the third electronic device do not establish a second communication connection, store the target data in a local database; When the second communication connection is established, upload the target data in the local database to the third electronic device.
6. The method according to claim 1, wherein The first electronic device obtains original data from the second electronic device by interacting with the second electronic device. After loading the dependencies of the target Flutter application, the method further includes: Process the original data in batches to obtain target data.
7. The method according to claim 6, characterized in that, The first electronic device is used to upload the target data to a third electronic device. After processing the original data in batches to obtain target data, the method further includes: Upload the target data to the third electronic device in batches.
8. A data interaction device for a Flutter application, characterized in that, Applied to a first electronic device, including: A creation module, configured to create a foreground service and a timing task for a target Flutter application on the first electronic device, and establish a first communication connection with a second electronic device when the target Flutter application is running in the foreground; A detection module, configured to detect whether the scheduled duration of the scheduled task has reached when the target Flutter application exits or returns to the previous level; An execution module, configured to execute the scheduled task when the scheduled duration of the scheduled task has reached; Wherein, the scheduled task includes: loading dependencies of the target Flutter application to establish the first communication connection and interacting with the second electronic device based on the first communication connection, and releasing the dependencies to disconnect the first communication connection when the data interaction is completed.
9. A first electronic device, characterized in that, The first electronic device includes the device according to claim 8; Alternatively, the first electronic device includes a memory and a processor, the memory is configured to store computer instructions, and the processor is configured to call the computer instructions from the memory to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program, when executed by a processor, implements the method according to any one of claims 1-7.