adb获取包名和界面名
- mac
- adb shell dumpsys window windows | grep mFocusedApp
- windows
- adb shell dumpsys window windows | findstr mFocusedApp
这个是在当前手机打开哪个界面获取的就是哪个界面的包名与界面
注意第一次连接时会有提示,需要连接两次才可以
C:\Users\i5ba0>adb shell dumpsys window windows | findstr mFocusedApp
adb server version (31) doesn't match this client (41); killing...
* daemon started successfully
adb.exe: device offlineC:\Users\i5ba0>adb shell dumpsys window windows | findstr mFocusedAppmFocusedApp=AppWindowToken{25d14d77 token=Token{27267376 ActivityRecord{1ee68611 u0 com.android.launcher3/.Launcher t1}}}C:\Users\i5ba0>
当我们打开设置时,包名与界面名变成了com.android.settings/.Settings t2
C:\Users\i5ba0>adb shell dumpsys window windows | findstr mFocusedAppmFocusedApp=AppWindowToken{3eede788 token=Token{3525d72b ActivityRecord{28fd037a u0 com.android.settings/.Settings t2}}}C:\Users\i5ba0>