Paste text on Android Emulator

后端 未结 20 1432
臣服心动
臣服心动 2020-12-07 07:10

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)

相关标签:
20条回答
  • 2020-12-07 07:13

    An easy way is there

    1. Activate keyboard in emulator.
    2. Click on the place you want to paste and long press (press until you see the word PASTE)
    3. Done.

    See original answer: https://www.quora.com/How-do-I-paste-text-from-my-computer-to-Android-emulator

    0 讨论(0)
  • 2020-12-07 07:15

    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
    
    0 讨论(0)
  • 2020-12-07 07:15

    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!

    0 讨论(0)
  • 2020-12-07 07:18

    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.

    0 讨论(0)
  • 2020-12-07 07:19

    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

    0 讨论(0)
  • 2020-12-07 07:21

    (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!

    0 讨论(0)
提交回复
热议问题