Paste text on Android Emulator

2019-01-16 00:13发布

Is there anyway to copy/paste (desktop's) clipboard content to EditView on Android Emulator?

(just for the sake to ease development/test)

17条回答
Melony?
2楼-- · 2019-01-16 00:32

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

Copy and Paste with the Android Emulator

查看更多
Fickle 薄情
3楼-- · 2019-01-16 00:33

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.

查看更多
戒情不戒烟
4楼-- · 2019-01-16 00:34

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.

查看更多
够拽才男人
5楼-- · 2019-01-16 00:34

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.

查看更多
Ridiculous、
6楼-- · 2019-01-16 00:37

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:

  • Syntax: telnet localhost <port>
  • Example: 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:

  • Syntax: sms send <senders phone number> <message>
  • Example: 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.

查看更多
Ridiculous、
7楼-- · 2019-01-16 00:39

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.

Setup

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
查看更多
登录 后发表回答