查看安卓手机当前打开正在查看的应用的包名
我们知道可以通过以下命令所有的包
`>adb shell pm list packages`
除了常见的应用,其他的我们只能靠猜
有什么办法比较方便知道应用的包名
靠谱的方法,首先打开你想知道包名的应用
比如我现在打开QQ
然后输入以下命令
```
C:\Users\Administrator>adb shell dumpsys window | findstr mCurrentFocus
mCurrentFocus=Window{cdd988a u0 com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity}
```
再或者我打开企业微信,然后输入以下命令
```
C:\Users\Administrator>adb shell dumpsys window | findstr mCurrentFocus
mCurrentFocus=Window{cc1adce u0 com.tencent.wework/com.tencent.wework.launch.WwMainActivity}
```
`adb shell dumpsys window windows | findstr mFocusedApp`
查看应用的类名
`adb shell dumpsys activity activities | findstr "Run"`
得到以下的输出
```
C:\Users\Administrator>adb shell dumpsys activity activities | findstr "Run"
Running activities (most recent first):
Run #0: ActivityRecord{8a4567e u0 com.carriez.flutter_hbb/.MainActivity t298}
Running activities (most recent first):
Run #0: ActivityRecord{26178d8 u0 com.oppo.launcher/.Launcher t1}
Running activities (most recent first):
Run #0: ActivityRecord{1310404 u0 com.tencent.wework/.launch.WwMainActivity t302}
Running activities (most recent first):
Run #0: ActivityRecord{a0c7d4b u0 com.tencent.mobileqq/.activity.SplashActivity t304}
Running activities (most recent first):
Run #1: ActivityRecord{4f725d8 u0 com.android.settings/.SubSettings t299}
Run #0: ActivityRecord{667635c u0 com.android.settings/.Settings t299}
Running activities (most recent first):
Run #1: ActivityRecord{3392335 u0 com.coloros.filemanager/.view.browser.FileBrowserActivity t301}
Run #0: ActivityRecord{953576a u0 com.coloros.filemanager/.Main t301}
Running activities (most recent first):
Run #0: ActivityRecord{6ae544 u0 com.android.incallui/.OppoInCallActivity t255}
C:\Users\Administrator>
```
查看到启动名为
` com.carriez.flutter_hbb/com.carriez.flutter_hbb.MainActivity`
通过以下命令也可以
`C:\Users\Administrator>adb shell dumpsys window w |findstr \/ |findstr name=`
```
mSurface=Surface(name=AssistOverlayBottom)/@0xbc10955
mSurface=Surface(name=ScreenDecorOverlay)/@0x7700c5b
mAnimationIsEntrance=true mSurface=Surface(name=NavigationBar)/@0x5757d93
mAnimationIsEntrance=true mSurface=Surface(name=StatusBar)/@0xad4c56c
mSurface=Surface(name=ColorOSEdgeFloatBar)/@0xc2a2f63
mSurface=Surface(name=com.coloros.floatassistant)/@0xfb621c2
mSurface=Surface(name=com.carriez.flutter_hbb/com.carriez.flutter_hbb.MainActivity)/@0x1fb71d0
mAnimationIsEntrance=true mSurface=Surface(name=com.android.systemui.ImageWallpaper)/@0xb839ae6
```
`adb shell dumpsys activity top | find "ACTIVITY"`
```
ACTIVITY com.android.incallui/.OppoInCallActivity 6ae544 pid=3663
ACTIVITY com.coloros.filemanager/.view.browser.FileBrowserActivity 3392335 pid=15693
ACTIVITY com.tencent.mobileqq/.activity.SplashActivity a0c7d4b pid=20706
ACTIVITY com.tencent.wework/.launch.WwMainActivity 1310404 pid=3585
ACTIVITY com.android.settings/.Settings$DevelopmentSettingsDashboardActivity 66cc4e3 pid=4594
ACTIVITY com.oppo.launcher/.Launcher 26178d8 pid=3297
ACTIVITY com.carriez.flutter_hbb/.MainActivity 8a4567e pid=6931
```