Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 580
GorvGoyl Avatar asked Nov 03 '18 10:11

GorvGoyl


1 Answers

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.
like image 73
aminography Avatar answered Nov 04 '22 19:11

aminography