In doing some Android automation scripts, such as the mobile phone QQ input Chinese chat content, due to the use of Robotium, Appium and other tools to do, because of TX signed verification, so log on QQ. Later only use the most stupid monkeyrunner to do, but it is completely simulated human clicks, and the data Chinese is very troublesome. To this end we have tried a variety of options, simply share:
1. Through the PC Clipboard and the Android simulator to share to achieve: the first to be entered in Chinese to the PC Clipboard, and then to the Android emulator paste into the QQ chat input box. Its disadvantage is, very unstable, sometimes successful, sometimes more inexplicable failure.
2. The ADB shell Input command can directly enter a string into the input box for the Android application, but the problem is that it does not support Unicode characters (only ASICC characters are supported). So I found a way to use the data on the Web to output the Unicode character as it is, and then convert it to the encoded character. For example: HTTPS://GITHUB.COM/BINGWEI/INPUTCHINESEVIAADB, the implementation of such a transformation, in the app copied to the Android clipboard, and then can be in the QQ chat boxes and other places to paste the good. Of course, there's a little bug in the utils/inputunicode.py file in this Gitlab project, and for Python 2.x, you need to encode encode (' Unicode-escape ') in the string followed by the ADB shell input.
The speed of this method is not very fast, but it is still good, because the UI Automation delay for a two seconds is also acceptable; we finally adopted this scheme, and now it is very stable to run.
3. Use an external rest server, make a key-value pair into rest sever, where key is in all English, and value can contain Chinese, and then pass the key into andoid through adb shell input, In Android, the remote Rest API is requested based on key to obtain value containing the Chinese character. This method has not been tried, but it should be feasible, but its efficiency estimate is less efficient than the 2nd method.
4. A special input method for Unicode, you can enter Unicode for adb shell input, which helps you to convert to characters such as Chinese. Never really tried.