Control and automate Android devices using ADB, uiautomator, and screencap.
adb devices. adb pair
adb connect
adb devices.Use the monkey tool to launch apps by package name:
adb shell monkey -p
Dump and pull the UI hierarchy to find coordinates:
adb shell uiautomator dump /sdcard/view.xml && adb pull /sdcard/view.xml ./view.xml
Then grep for text or resource IDs to find bounds="[x1,y1][x2,y2]".
adb shell input tap adb shell input text "" (Note: Use %\s for spaces in some environments or handle quoting carefully)adb shell input keyevent (Home: 3, Back: 4, Power: 26, Search: 84, Enter: 66)adb shell input swipe Take a screenshot to verify the state:
adb shell screencap -p /sdcard/screen.png && adb pull /sdcard/screen.png ./screen.png
input keyevent 84 to trigger search in many apps.sleep between commands to allow the UI to update.[x1,y1][x2,y2] for reliable taps.共 1 个版本