How to copy some text to android system clipboard using ADB?

こ雲淡風輕ζ 提交于 2020-01-03 11:02:31

问题


I want to automate some stuff on my rooted android Oreo and can't seem to find a way to copy some text to clipboard. I can paste the copied text adb shell input keyevent 279 so hoping to get some way to copy text also.

P.S: not looking for answers suggesting adb shell input text [text] cause it's slow.


回答1:


It seems there are 2 ways to copy a text into android clipboard using adb shell.

  1. Using service call clipboard 2 i32 1 i32 0 s16 "text" (Deprecated and doesn't work on android 8)
  2. Using an external service and pass it the text through intent extras. It receives the text then tries to copy it into the clipboard. For example we can install Clipper on the device then run am broadcast -a clipper.set -e text "text" in adb shell.


来源:https://stackoverflow.com/questions/53130653/how-to-copy-some-text-to-android-system-clipboard-using-adb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!