adb 常用命令

windows下查看命令

查看当前应用信息

adb shell dumpsys window w |findstr / |findstr name=

查看当前所有设备

adb devices

设置设别的连接端口

adb -s 设备名 tcpip  端口号

例如: adb -s  myphone tcpip 6666

该命令用于多设备同时进行操作

查看前台 Activity

命令:

adb shell dumpsys activity activities | grep mResumedActivity

输出示例:

mResumedActivity: ActivityRecord{8079d7e u0 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher t42}

其中的 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher 就是当前处于前台的 Activity。

在 Windows 下以上命令可能不可用,可以尝试 adb shell dumpsys activity activities | findstr mResumedActivity 或 adb shell "dumpsys activity activities | grep mResumedActivity"

原文地址:https://www.cnblogs.com/wangdongpython/p/11241074.html