Is there an easy way to copy/paste (desktop's) clipboard content to EditView
on Android Emulator?
(just for the sake to ease development/test)
Is there an easy way to copy/paste (desktop's) clipboard content to EditView
on Android Emulator?
(just for the sake to ease development/test)
With v25.3.x of the Android Emulator & x86 Google API Emulator system images API Level 19 (Android 4.4 - Kitkat) and higher, you can simply copy and paste from your desktop with your mouse or keyboard.
This feature was announced with Android Studio 2.3
~/.android/avd/
.ini
files? –
Bluegrass In a terminal, type adb shell input text 'my string here. With some characters escaped like \$ that'
Note that an alternative method for including spaces in the text is to substitute %s
for each space
character.
adb shell input text "
pbpaste"
–
Kevenkeverian "Hello World"
only sends hello
to my avd. –
Cortese 'ლ\(ಠ益ಠლ\)'
, it just says 'Killed' or appears to succeed and nothing is typed, nor do I have anything pasteable in the emulator. The SMS method (I tried from DDMS) doesn't even seem to be working here, it displays as "?(????)" :( –
Lingual adb shell input text '%*'
–
Ferromagnetic adb shell input text "This%sis%stext\nDoes%snot%work%here."
prints "This is text\nDoes not work here.". –
Derzon alias adbpaste="pbpaste|sed 's/ /%s/g'|xargs adb shell input text"
. Doesn't handle all special characters but it was good enough for my purposes (pasting email addresses and alphanumeric strings.) –
Fidelfidela adb shell input text "'"$(xclip -selection c -o)"'"
–
Proximate With v25.3.x of the Android Emulator & x86 Google API Emulator system images API Level 19 (Android 4.4 - Kitkat) and higher, you can simply copy and paste from your desktop with your mouse or keyboard.
This feature was announced with Android Studio 2.3
~/.android/avd/
.ini
files? –
Bluegrass Just copy from wherever, click and hold on the emulator phone's edit text where you want the text to go (kind of like you would press and hold to paste on an actual phone), the PASTE option will appear, then PASTE.
I usually send the text I want to copy as an sms message through telnet and then copy the text from the sms message. Here's how:
Connect through telnet:
telnet localhost <port>
telnet localhost 5554
(5554 is the default port. The title bar of the emulator shows the port that is being used, so you can see if it's different).
Send message:
sms send <senders phone number> <message>
sms send 1231231234 This is the message you want to send
(You can just make up the senders phone number)
This works really well for links as the message is automatically converted into a hyperlink which you can click without having to copy / paste it into the browser.
Once the emulator receives the message you can copy it and paste it wherever you like.
adb
. See my answer. –
Pickel echo sms send 0 `pbpaste | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\\\n/g'` | telnet localhost 5554
–
Flange sms
command? my telnet on macos doesn't have it –
Salt Not sure if that's useful, but, if you need a long URL from desktop browser to be opened in mobile browser, you can send SMS with that URL and open directly from message app.
For Mac users, a MUCH easier way is to do this right in the android emulator:
If you are using Android Studio on a Mac, you may need to provide the full path to the adb
executable. To find this path, open:
Android Studio > Tools > Android > SDK Manager
Copy the path to the SDK location. The adb
executable will be within a platform-tools
directory. For me, this was the path:
~/Library/Android/sdk/platform-tools/adb
Now you can run this command:
~/Library/Android/sdk/platform-tools/adb shell input text 'thetextyouwanttopaste'
~/Library/Android/sdk/platform-tools/
to your PATH variable to make this easier to use. –
Arianaariane On Linux this will paste text directly from the clipboard
adb shell input text "'$(xclip -selection c -o)'"
Also it very useful to create global keyboard shortkey with this command for example Ctrl+Shift+Super+V
Just click the left mouse button and keep it down for 1 full second, then release it.
A paste button will appear.
Click the paste button and the text will be copied.
Only For API level >= 24
Copy any text from your local machine and then simply run this command
adb shell input keyevent 279
Make sure In Android Emulator Settings the Enable Clipboard Sharing
options is enabled
My case was that my emulator pasted something that I copied few days earlier and never pasted the last thing in my current clipboard of my laptop.
To solve that I made my emulator starts from cold boot
rather than quick boot
.
I got tired of this problem so I just made this alias to handle it:
alias ap="pbpaste | xargs adb shell input text"
Then when you open a new terminal window, typing "ap" will paste whatever is on your clipboard into the emulator's actively selected text field.
Simply add this to your profile (for most users that's ~/.bash_profile
for zsh users that's ~/.zshrc
) to make the alias available everywhere. Alternatively, if you're a bash user (the default for MacOS), then you can run the following command in the terminal to set it up for you:
echo "alias ap='pbpaste | xargs adb shell input text'" >> ~/.bash_profile && source ~/.bash_profile
alias ap="adb shell input text `pbpaste`"
–
Odeen 'alias' is not recognized as an internal or external command, operable program or batch file.
what to do –
Whelp pbpaste
is macOS specific, but there is probably something similar on Windows. alias
also might not be available to you depending on the shell you're using. –
Arianaariane Adding another answer, since this is the only (weird) way I was able to fix this.
There's a (non-working) setting called "Enable clipboard sharing". It does not work at first:
However, once you enabled that setting you have to use built-in copy-paste at least once on the device, only THEN it starts working (when the Android keyboard is open, as soon as you copy something on Windows/Mac, the value becomes available on the Android keyboard for a little while).
Also keep in mind that the emulator watches the host-operating system's "copy" event and only offers the text after that.
I.e. if you've already had something in the clipbaord before opening the emulator, it won't be available, since there was no event to catch.
maybe a little bit tricky, but you could send an sms to the emulator by using the emulator control. then you do not have to retype all the text if it is longer and can copy-paste it in the emulator.
another way: connect to emulator via "telnet localhost PORT" and then use hardware event sending to send a text input event to the emulator (needs to be UTF-8). look at this
Made this Windows application that allows users to copy paste to Android emulators or connected devices from a visual interface. https://github.com/Florin-Birgu/Android-Copy-Paste
You can do this without workarounds too. Just click and hold for a bit in the input field till the paste notification appears and then click on paste. That's it!
An easy way is there
See original answer: https://www.quora.com/How-do-I-paste-text-from-my-computer-to-Android-emulator
Have you looked at C2DM? chrome2phone and fox2phone can send links and clipboard text and automatically copy it on the phone. Also, try using the adb shell. There's a service command (/system/bin/service) which can use services (service call clipboard ...). The transaction codes are 1, 2, and 3, for getClipboardText, setClipboardText, and hasClipboardText respectively.
Using Visual Studio Emulator, Here's my method.
First Mound a virtual sd card:
Set up a text file to transfer text:
Whenever I need to send text to the clip board.
Once set up it pretty easy to repeat. The same method would be applicable to other emulators by you may need to use a different method to push your text file to emulator.
(converting comment discussion to answer)
only solution on windows: https://github.com/gcb/AdbPaste
wrote it in a couple hours to work around this problem. I am now back on 100% linux, so feel free to join it as a contributor or maintainer!
For Mac and Linux try this function in your aliases_bash file (located in /etc/aliases_bash for Mac folks, be sure to use sudo vim /etc/aliases_bash)
function adbtx {
userinput="$(sed 's/ /%s/g' <<< $1)"
adb shell input text "${userinput}";
}
export -f adbtx
Then in the command line enter:
adbtx 'Your text to emulator input'
'Your text to emulator input' will be input on the emulator text field.
Kudos to Eliot for his substitution string for sed.
Write command: adb devices (it will list the device currently connected) Select Textbox where you want to write text. Write command: adb shell input text "Yourtext" (make sure only one device is connected to run this command) Done!
I came here looking for a solution to the same problem, and ended up writing an Android application to solve this problem. You can download it at http://www.box.net/shared/6203bn441bfltkimajmk. Just give a URL via Preferences menu to point to a place where you can change the Web response easily. The first line of the Web response will be copied to your emulator's clipboard for you. More details can be found at http://agilesc.barryku.com/?p=255.
Actually, in my case restarting the MacBook and running the emulator with this command fixed the issue:
emulator -avd Pixel_5_API_31 -wipe-data
remember that you should use your emulator device, to see the emulator list use this command:
emulator -list-avds
Sometimes the clipboard of the emulator is not synched with the system clipboard. It is a bug.
But you can consider the ability to change the value of a variable in debug mode: https://www.jetbrains.com/help/idea/tutorial-set-value.html#solution (Android Studio based on IntelliJ IDEA, so I hope that this link will be helpful)
If your app reads the text from clipboard, you can change the value of the variable for this text and past your text there
To my understanding, It's totally depends on the Emulator that you use
© 2022 - 2025 — McMap. All rights reserved.