Method and system for solving conflict between multiple code scanning guns and input method in Android system
Through the collaborative work of the InputEventReceiver class and the ViewRootImpl class, the code scanning gun and keyboard events are distinguished, and the problem of conflict between the code scanning gun and the input method in the Android system is solved, the application stability and user experience are improved, and the device management is simplified.
Patent Information
- Application Number
- CN202411268975.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-31
AI Technical Summary
In Android systems, the scanner gun and the input method are prone to conflict, resulting in the scanning event being consumed by the input method and causing the garbled code problem. The existing solutions require each application to implement event interception separately, which is inefficient and has high time cost.
Receive input events through the InputEventReceiver class and distribute them to the shouldSkipIme method of the ViewRootImpl class to determine whether the event is a scanner. If so, skip the IME processing and output it directly to the EditText control. Users can add or cancel the scanner device information by themselves to distinguish the scanner. Code gun and keyboard events.
It effectively avoids the conflict between the code scanning gun and the input method, improves the stability and user experience of the application, and does not require each application to implement event interception separately, simplifying device management.
Smart Images

Figure CN119226003A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Android systems, and more specifically, to a method and system for resolving conflicts between multiple barcode scanners and input methods in an Android system. Background Art
[0002] ARM motherboard devices are widely used in retail, logistics, industry, and medical fields. Currently, the mainstream operating system for smart terminals is Android. In the retail field, using scanners for barcode or QR code payment has become a common operation.
[0003] However, there is a problem with retail devices on the market when they leave the factory: when a user clicks on an EditText control, an input method pops up. If the input method is not an English input method, and the scanned one-dimensional code or two-dimensional code contains English or special characters, there will be a conflict between the input method and the scanning event. This will cause the scanning event to be consumed by the input method, thereby inputting the corresponding characters on the virtual keyboard, causing garbled characters. The mainstream method to solve this problem in the market is to rewrite the dispatchKeyEventPreIme event in the application to intercept the event before the input method. However, this approach has a disadvantage, that is, different applications need to implement this function separately, which is inefficient and time-consuming. Summary of the invention
[0004] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a method for resolving conflicts between multiple barcode scanners and input methods in an Android system is provided, and a system for resolving conflicts between multiple barcode scanners and input methods in an Android system is also provided.
[0005] The technical solution adopted by the present invention to solve its technical problem is:
[0006] Construct a solution to the conflict between multiple barcode scanners and input methods in an Android system, which includes the following steps:
[0007] When the system detects an input event, the InputEventReceiver class receives the input event;
[0008] The InputEventReceiver class distributes the ViewRootImpl class, and distributes the event to the shouldSkipIme method in the QueuedInputEvent internal class of ViewRootImpl according to the deliverInputEvent method in the ViewRootImpl class;
[0009] The shouldSkipIme method determines whether it is a keyboard event based on the condition mEvent.getSource() == InputDevice.SOURCE_KEYBOARD. If so, it proceeds to the next step, otherwise the system processes it as other events;
[0010] Enter the supportScannerGun method to determine whether the device ProductId and VendorId corresponding to the event are equal to the ProductId and VendorId values of the barcode scanner entered by the user on the application side;
[0011] If the device information is equal to the information stored by the application, the IME processing event is skipped and the event is directly output to the EditText control. Otherwise, the system handles it as other events.
[0012] The method for resolving conflicts between multiple barcode scanners and input methods in the Android system of the present invention is as follows: the method for the application end user to input the ProductId and VendorId values of the barcode scanner is:
[0013] After booting up, the app for processing the barcode scanner will start automatically to determine whether the device is connected to a keyboard device, which includes both a keyboard and a barcode scanner. If yes, proceed to the next step, otherwise end;
[0014] If the device is connected to a barcode scanner, a prompt box will pop up. Follow the prompt to add the barcode scanner device to the system. If a physical keyboard is connected, cancel adding it to the system according to the prompt.
[0015] The method for resolving conflicts between multiple barcode scanners and input methods in the Android system described in the present invention, wherein the system allows the device information of up to 9 barcode scanners to be saved. If the number exceeds the limit, the user will be prompted to clear the data, re-plug the barcode scanner, and then add the device information to the system.
[0016] The method for resolving conflicts between multiple barcode scanners and input methods in an Android system described in the present invention, wherein the other events include mouse and touch events.
[0017] A system for resolving conflicts between multiple barcode scanners and input methods in an Android system, wherein the system comprises an event detection unit and an event recognition processing unit;
[0018] The event detection unit is used to receive input events through the InputEventReceiver class, the InputEventReceiver class distributes the ViewRootImpl class, and distributes the event to the shouldSkipIme method in the QueuedInputEvent internal class of the ViewRootImpl according to the deliverInputEvent method in the ViewRootImpl class;
[0019] The event identification processing unit is used to determine whether it is a keyboard event through the shouldSkipIme method with mEvent.getSource() == InputDevice.SOURCE_KEYBOARD as the condition. If not, the system processes it as other events. If so, it enters the supportScannerGun method to determine whether the device ProductId and VendorId corresponding to the event are equal to the ProductId and VendorId values of the barcode scanner entered by the user on the application side; if the device information is equal to the information stored in the application, the IME processing event is skipped and directly output to the EditText control, otherwise the system processes it as other events.
[0020] In the Android system of the present invention, the system for resolving conflicts between multiple barcode scanners and input methods, the application end user inputs the barcode scanner ProductId and VendorId values using the following method:
[0021] After booting up, the app for processing the barcode scanner will start automatically to determine whether the device is connected to a keyboard device, which includes both a keyboard and a barcode scanner. If yes, proceed to the next step, otherwise end;
[0022] If the device is connected to a barcode scanner, a prompt box will pop up. Follow the prompt to add the barcode scanner device to the system. If a physical keyboard is connected, cancel adding it to the system according to the prompt.
[0023] The system for resolving conflicts between multiple barcode scanners and input methods in an Android system of the present invention allows the device information of up to 9 barcode scanners to be saved. If the number is exceeded, the user will be prompted to clear the data, re-plug the barcode scanner, and then add the device information to the system.
[0024] The system for resolving conflicts between multiple barcode scanners and input methods in an Android system described in the present invention, wherein the other events include mouse and touch events.
[0025] The beneficial effect of the present invention is that since the scanner event and the physical keyboard event are the same event, through the built-in scanner application, the user can select whether the inserted device is a scanner, thereby distinguishing between a scanner and a keyboard. In this way, retail devices on the market no longer need to solve the problem of garbled characters between scanners and input methods, thereby improving the stability of the overall application and user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. The drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work:
[0027] Figure 1 This is a flow chart of a method for resolving conflicts between multiple barcode scanners and input methods in an Android system according to a preferred embodiment of the present invention;
[0028] Figure 2 This is a client setting flow chart of a method for resolving conflicts between multiple barcode scanners and input methods in an Android system according to a preferred embodiment of the present invention;
[0029] Figure 3 It is a principle block diagram of a system for resolving conflicts between multiple barcode scanners and input methods in an Android system in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the following will be described clearly and completely in combination with the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are partial embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0031] In the preferred embodiment of the present invention, a method for resolving conflicts between multiple barcode scanners and input methods in an Android system is as follows: Figure 1 See also Figure 2 , including the following steps:
[0032] When the system detects an input event, the InputEventReceiver class receives the input event;
[0033] The InputEventReceiver class distributes the ViewRootImpl class, and distributes the event to the shouldSkipIme method in the QueuedInputEvent class of the ViewRootImpl internal class according to the deliverInputEvent method in the ViewRootImpl class; the shouldSkipIme method determines whether it is a keyboard event according to the condition mEvent.getSource() == InputDevice.SOURCE_KEYBOARD. If so, proceed to the next step, otherwise the system processes it as other events;
[0034] Enter the supportScannerGun method to determine whether the device ProductId and VendorId corresponding to the event are equal to the ProductId and VendorId values of the barcode scanner entered by the user on the application side;
[0035] If the device information is equal to the information stored by the application, the IME processing event is skipped and the event is directly output to the EditText control. Otherwise, the system handles it as other events.
[0036] On the system side, keyboard events are distinguished from other events (such as mouse, touch events, etc.) and the IME is skipped and output directly to the EditText control; since scanner events and physical keyboard events are the same event, through the built-in scanner application, users can choose whether the inserted device is a scanner, thereby distinguishing between scanners and keyboards. In this way, retail devices on the market no longer need to solve the problem of garbled characters between scanners and input methods, which improves the stability of the overall application and user experience.
[0037] On the user side, Figure 2 As shown in the user-side flow chart: after booting up, the app for processing the barcode scanner will start automatically to determine whether the device is connected to a keyboard device (i.e. keyboard, barcode scanner). If the device is connected to a barcode scanner, a prompt box will pop up, and the barcode scanner device will be added to the system according to the prompt content; if a physical keyboard is connected, cancel the addition to the system according to the prompt. Considering daily usage and preventing too many barcode scanner devices from being added, which will cause the device information to be read for too long, currently a maximum of 9 barcode scanner device information is allowed to be saved. If it exceeds the limit, the user will be prompted to clear the data and re-plug the barcode scanner before adding the device information to the system.
[0038] The user side is responsible for adding the device information of the barcode scanner to the system, and the system side is responsible for determining whether the input data (barcode scanning by the barcode scanner, keyboard keys, etc.) is sent by the added device.
[0039] This technological innovation provides an efficient and reliable solution to the conflict between scanners and input methods in retail devices, bringing substantial improvements to the industry. The application of this technology is expected to be widely used in the retail field and other related fields, improving the overall intelligence and user-friendliness of the equipment. Through this innovation, it has a positive impact on the development of smart terminals and user experience.
[0040] A system for resolving conflicts between multiple barcode scanners and input methods in an Android system, such as Figure 3 As shown, the system includes an event detection unit 100 and an event identification processing unit 101;
[0041] The event detection unit 100 is used to receive input events through the InputEventReceiver class, the InputEventReceiver class distributes the ViewRootImpl class, and distributes the event to the shouldSkipIme method in the QueuedInputEvent internal class of the ViewRootImpl according to the deliverInputEvent method in the ViewRootImpl class;
[0042] The event identification processing unit 101 is used to determine whether it is a keyboard event through the shouldSkipIme method with mEvent.getSource() == InputDevice.SOURCE_KEYBOARD as the condition. If not, the system processes it as other events. If so, it enters the supportScannerGun method to determine whether the device ProductId and VendorId corresponding to the event are equal to the ProductId and VendorId values of the barcode scanner entered by the user on the application side; if the device information is equal to the information stored in the application, the IME processing event is skipped and directly output to the EditText control, otherwise the system processes it as other events;
[0043] On the system side, keyboard events are distinguished from other events (such as mouse, touch events, etc.) and the IME is skipped and output directly to the EditText control; since scanner events and physical keyboard events are the same event, through the built-in scanner application, users can choose whether the inserted device is a scanner, thereby distinguishing between scanners and keyboards. In this way, retail devices on the market no longer need to solve the problem of garbled characters between scanners and input methods, which improves the stability of the overall application and user experience.
[0044] On the user side, Figure 2 As shown in the user-side flow chart: after booting up, the app for processing the barcode scanner will start automatically to determine whether the device is connected to a keyboard device (i.e. keyboard, barcode scanner). If the device is connected to a barcode scanner, a prompt box will pop up, and the barcode scanner device will be added to the system according to the prompt content; if a physical keyboard is connected, cancel the addition to the system according to the prompt. Considering daily usage and preventing too many barcode scanner devices from being added, which will cause the device information to be read for too long, currently a maximum of 9 barcode scanner device information is allowed to be saved. If it exceeds the limit, the user will be prompted to clear the data and re-plug the barcode scanner before adding the device information to the system.
[0045] The user side is responsible for adding the device information of the barcode scanner to the system, and the system side is responsible for determining whether the input data (barcode scanning by the barcode scanner, keyboard keys, etc.) is sent by the added device.
[0046] This technological innovation provides an efficient and reliable solution to the conflict between scanners and input methods in retail devices, bringing substantial improvements to the industry. The application of this technology is expected to be widely used in the retail field and other related fields, improving the overall intelligence and user-friendliness of the equipment. Through this innovation, it has a positive impact on the development of smart terminals and user experience.
[0047] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A solution to conflicts between multiple barcode scanners and input methods in an Android system, characterized in that: The following steps are involved: When the system detects an input event, the InputEventReceiver class receives the input event; The InputEventReceiver class distributes the ViewRootImpl class, and distributes the event to the shouldSkipIme method in the QueuedInputEvent internal class of ViewRootImpl according to the deliverInputEvent method in the ViewRootImpl class; The shouldSkipIme method determines whether it is a keyboard event based on the condition mEvent.getSource() == InputDevice.SOURCE_KEYBOARD. If so, it proceeds to the next step, otherwise the system processes it as other events; Enter the supportScannerGun method to determine whether the device ProductId and VendorId corresponding to the event are equal to the ProductId and VendorId values of the barcode scanner entered by the user on the application side; If the device information is equal to the information stored by the application, the IME processing event is skipped and the event is directly output to the EditText control. Otherwise, the system handles it as other events.
2. The method for resolving conflicts between multiple barcode scanners and input methods in an Android system according to claim 1, characterized in that: The user on the application side enters the ProductId and VendorId values of the barcode scanner: After booting up, the app for processing the barcode scanner will start automatically to determine whether the device is connected to a keyboard device, which includes both keyboards and barcode scanners. If yes, proceed to the next step, otherwise end; If the device is connected to a barcode scanner, a prompt box will pop up. Follow the prompt to add the barcode scanner device to the system. If a physical keyboard is connected, cancel adding it to the system according to the prompt.
3. The method for resolving conflicts between multiple barcode scanners and input methods in an Android system according to claim 2, characterized in that: The system allows to save the device information of up to 9 barcode scanners. If the number is exceeded, the user will be prompted to clear the data, re-plug the barcode scanner, and then add the device information to the system.
4. The method for resolving conflicts between multiple barcode scanners and input methods in an Android system according to claim 1, characterized in that: The other events include mouse and touch events.
5. A system for resolving conflicts between multiple barcode scanners and input methods in an Android system, characterized in that: The system includes an event detection unit and an event identification processing unit; The event detection unit is used to receive input events through the InputEventReceiver class, the InputEventReceiver class distributes the ViewRootImpl class, and distributes the event to the shouldSkipIme method in the QueuedInputEvent internal class of the ViewRootImpl according to the deliverInputEvent method in the ViewRootImpl class; The event identification processing unit is used to determine whether it is a keyboard event through the shouldSkipIme method with mEvent.getSource() == InputDevice.SOURCE_KEYBOARD as the condition. If not, the system processes it as other events. If so, it enters the supportScannerGun method to determine whether the device ProductId and VendorId corresponding to the event are equal to the ProductId and VendorId values of the barcode scanner entered by the user on the application side; if the device information is equal to the information stored in the application, the IME processing event is skipped and directly output to the EditText control, otherwise the system processes it as other events.
6. The system for resolving conflicts between multiple barcode scanners and input methods in an Android system according to claim 5, characterized in that: The user on the application side enters the ProductId and VendorId values of the barcode scanner: After booting up, the app for processing the barcode scanner will start automatically to determine whether the device is connected to a keyboard device, which includes both keyboards and barcode scanners. If yes, proceed to the next step, otherwise end; If the device is connected to a barcode scanner, a prompt box will pop up. Follow the prompt to add the barcode scanner device to the system. If a physical keyboard is connected, cancel adding it to the system according to the prompt.
7. The system for resolving conflicts between multiple barcode scanners and input methods in an Android system according to claim 6, characterized in that: The system allows to save the device information of up to 9 barcode scanners. If the number is exceeded, the user will be prompted to clear the data, re-plug the barcode scanner, and then add the device information to the system.
8. The system for resolving conflicts between multiple barcode scanners and input methods in an Android system according to claim 5, characterized in that: The other events include mouse and touch events.
