adb shell am broadcast -a com.example.MY_ACTION adb shell am broadcast -a android.intent.action.BOOT_COMPLETED adb shell am broadcast -n com.example.app/.MyReceiver -a com.example.MY_ACTION -e msg hello
force-stop —— 强制停止应用
1
adb shell am force-stop com.example.app
kill —— 杀进程
1 2
adb shell am kill com.example.app # 杀后台进程 adb shell am kill-all # 杀所有后台进程
任务栈与 Activity 管理
1 2 3 4 5
adb shell am stack list # 列出任务栈(旧版本) adb shell am task list # 列出任务 adb shell am task lock <taskId> # 锁定任务(屏幕固定) adb shell am task resize <taskId> w h # 调整任务窗口大小 adb shell am start -n ... --activity-clear-task # 清空任务栈
其他常用
1 2 3 4 5 6 7
adb shell am instrument -w com.example.test/androidx.test.runner.AndroidJUnitRunner # 跑测试 adb shell am monitor # 监控崩溃/ANR adb shell am hang # 挂起(调试) adb shell am dumpheap <pid> <file> # dump 堆内存 adb shell am profile start <process> <file> # 性能采样 adb shell am set-debug-app -w com.example.app # 设为调试应用并等待 adb shell am clear-debug-app