I need to paste text into the Android emulator clipboard using adb shell. tried on Android 1.6 and 2.3.1
I tried to use adb shell command: clipboard:[android.text.iclipboard]
"service call clipboard" where service codes are 1, 2, and 3, for getClipboardText, setClipboardText, and hasClipboardText respectively.
service call clipboard 2 s16 thisisinsertedtext
does not seem to work while
service call clipboard 1
shows the content of clipboard:
service call clipboard 1
Result: Parcel(
0x00000000: 00000000 00000001 00000001 00000004 '................'
0x00000010: 00650074 00740078 00000000 't.e.x.t..... ')
Please advise how to set a value for emulator clipboard!
Use below command.
I think that the first one, "i32 1" is how many elements in clipboard. So, just one. Second is a length of string. The command written above shows...
So, my question is, is there any way to copy unicode string? I mean, muti-byte character sets, like Korean. I tried many way, but it failed.
Try this:
i32: Write the integer INT into the send parcel.
s16: Write the UTF-16 string STR into the send parcel.
Using adb shell command directly do not work since API Level 11.
Here is a solution.
That is OK.
"你好吗" is Chinese character.
The second 'i32 1' can be any integer, maybe...
Looks like all 3 old methods are deprecated since API Level 11 so it won’t work for ICS
Not clear if it's even possible to make it work with service call clipboard anymore...
www.androidjavadoc.com/1.0_r1_src/constant-values.html
http://developer.android.com/reference/android/content/ClipboardManager.html
http://developer.android.com/guide/topics/text/copy-paste.html
There is an open source python script that can deal with the severe limitations: https://github.com/gcb/AdbPaste - and it works well enough except for long clipboard file uploads it's incredibly slow (200 line text file can take 20 minutes).
I found some code on GitHub for an app called clipper that can use adb to populate clipboard via a broadcast intent. I enhanced it to read from a file, the enhanced code is here: https://github.com/RoundSparrow/clipper
Build the app, install on the device. Now I can use ADB commands to populate the clipboard via a file. Works like a charm for a 3 page script I need to upload. Essentially you use like this:
It's much faster AdbPaste, it takes only a second or two regardless of the size of the clipboard content.