參考:https://github.com/mzlogin/awesome-adb
查看版本:
adb version
查看連接設(shè)備:
adb devices
安裝與卸載
-
安裝一個 APK:
adb install demo.apk
adb install Users\xxx\Desktop\demo.apk
-
保留數(shù)據(jù)和緩存文件,重新安裝 APK:
adb install -r demo.apk
-
安裝 APK 到 sd 卡:
adb install -s demo.apk
-
查看應(yīng)用安裝路徑:
adb shell pm path com.example.demo
-
直接卸載:
adb uninstall com.example.demo
-
卸載 APP 但保留數(shù)據(jù)和緩存文件:
adb uninstall -k com.example.demo
-
清除應(yīng)用數(shù)據(jù)與緩存:
adb shell pm clear com.example.demo
列出包名
-
列出手機裝的所有 APP 的包名:
adb shell pm list packages
-
列出系統(tǒng)應(yīng)用的所有包名:
adb shell pm list packages -s
-
列出除了系統(tǒng)應(yīng)用的第三方應(yīng)用包名:
adb shell pm list packages -3
-
使用 grep 來過濾:
adb shell pm list packages | grep qq
與應(yīng)用交互:
-
啟動應(yīng)用:
start [options] <INTENT>
adb shell am start -n com.example.demo/.MainActivity
-
強制停止應(yīng)用:
force-stop <packagename>
adb shell am force-stop com.example.demo
-
啟動服務(wù):
startservice [options] <INTENT>
adb shell am startservice com.example.demo/.MainService
-
停止服務(wù):
stopservice [options] <INTENT>
adb shell am stopservice com.example.demo/.MainService
-
發(fā)送廣播:
broadcast [options] <INTENT>
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n com.example.demo/.BootCompletedReceiver
文件管理
-
復(fù)制設(shè)備里的文件到電腦:
adb pull <設(shè)備里的文件路徑> [電腦上的目錄]
adb pull /sdcard/sr.mp4 ~/tmp/
-
復(fù)制電腦里的文件到設(shè)備:
adb push <電腦上的文件路徑> <設(shè)備里的目錄>
adb push ~/sr.mp4 /sdcard/
查看日志:
adb logcat
重啟:
adb reboot
獲取 root 權(quán)限:
adb root
檢測設(shè)備是否已 root:
adb shell
su
此時命令行提示符是 $ 則表示沒有 root 權(quán)限,是 # 則表示已 root。
查看連接過的 WiFi 密碼:
需要 root 權(quán)限
adb shell
su
cat /data/misc/wifi/*.conf
退出 adb shell:
$ exit
查看進程:
adb shell ps
獲取信息
-
獲取序列號
$adb get-serialno
02ae0c1021089daf
-
獲取 MAC 地址
$adb shell cat /sys/class/net/wlan0/address
bc:f5:ac:f9:f7:c8
-
查看設(shè)備型號
$adb shell getprop ro.product.model
Nexus 5
-
查看 Android 系統(tǒng)版本
$adb shell getprop ro.build.version.release
7.0.1
-
查看屏幕分辨率
$adb shell wm size
Physical size: 1080×1920
-
查看屏幕密度
$adb shell wm density
Physical density: 480
其他


