Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pasting text into Android emulator clipboard using adb shell

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!

like image 712
Raptorion Avatar asked Sep 02 '11 12:09

Raptorion


People also ask

How do I copy and paste in adb shell?

As you would just "CTRL+V" on windows, I just need to "CTRL+V" on Android if you know what I mean. Not directly through adb. If you have root, you could create a background system service that responds to an intent, and upon receiving the intent, inject a key sequence equivalent to paste (Ctrl + V).

How do I paste text from clipboard Android?

On your Android device, open an app in which you can input text, such as Mail or Messages. Tap any area where you can enter text to display the keyboard. Tap the clipboard icon in the toolbar above the keyboard and you should see the text you copied from Windows. Tap the text to insert it into the current area.

How do you create a clipboard on Android?

Android provides the library of ClipboardManager and ClipData and ClipData. item to use the copying and pasting framework.In order to use clipboard framework, you need to put data into clip object, and then put that object into system wide clipboard.


2 Answers

Use below command.

service call clipboard 2 i32 1 i32 18 s16 thisisinsertedtext

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...

Result: Parcel(00000000 '....') This usually means OK, no error.

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.

like image 96
Jeonghwan Avatar answered Sep 20 '22 03:09

Jeonghwan


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...

static final int    TRANSACTION_getClipboardText 1
static final int    TRANSACTION_hasClipboardText 3
static final int    TRANSACTION_setClipboardText 2

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

like image 21
Same old guy... Avatar answered Sep 18 '22 03:09

Same old guy...