Android还为开发者提供了adb(Android Debug Bridge),这是非常强大的调试工具。最常用的自然是logcat来显示日志记录。
方法一:
1、cmd命令中输入:adb shell 进入shell命令模式
2、shell中输入:logcat | grep ActivityManager 真机运行应用,可以实时 查看当前正在运行的Activity;
I/ActivityManager( 936): START u0 {cmp=com.example.chenzongwen.myapplication/.LeakActivity} from uid 10251 from pid 1630 on display 0
D/ActivityManager( 936): Delay resumeKeyDispatchingLocked() to avoid deadlock.
I/ActivityManager( 936): [AppLaunch] Displayed Displayed com.example.chenzongwen.myapplication/.LeakActivity: +155ms
D/ActivityManager( 936): AP_PROF:AppLaunch_LaunchTime:com.example.chenzongwen.myapplication/.LeakActivity:155:20438126
D/ActivityManager( 936): ACT-IDLE_NOW_MSG from windowsVisible() for idle: ActivityRecord{379aa884 u0 com.example.chenzongwen.myapplication/.LeakActivity t29}
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
com.example.chenzongwen.myapplication 为包名 LeakActivity 是当前活动的activity。
方法二:
1.cmd命令中输入:adb shell dumpsys activity activities
查看
Running activities (most recent first):
TaskRecord{35e0a397 #1 A=com.oppo.launcher U=0 sz=1}
Run #0: ActivityRecord{1adfa134 u0 com.oppo.launcher/.Launcher t1}
mLastPausedActivity: ActivityRecord{1adfa134 u0 com.oppo.launcher/.Launcher t1}
mFocusedActivity: ActivityRecord{379aa884 u0 com.example.chenzongwen.myapplication/.LeakActivity t29}
mFocusedStack=ActivityStack{47d984 stackId=1, 3 tasks} mLastFocusedStack=ActivityStack{47d984 stackId=1, 3 tasks}
mSleepTimeout=false
mCurTaskId=29
mUserStackInFront={}
mActivityContainers={0=ActivtyContainer{0}A, 1=ActivtyContainer{1}A}
[BMW]FLOATING STACK INFO:
Display Info:ActivityDisplay={0 numStacks=2 numFrontFloatStacks=0 numBackFloatStacks=0}
Front Float Stacks(from top to bottom):
Back Float Stacks:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
com.example.chenzongwen.myapplication 为包名 LeakActivity 是当前活动的activity。
- 顶
- 0
- 踩