Android 如何快速定位当前页面是哪个Activity or Fragment
生活随笔
收集整理的這篇文章主要介紹了
Android 如何快速定位当前页面是哪个Activity or Fragment
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在日常需求開發中,經常碰到不太熟悉的模塊,如何快速定位相應頁面對應的Activity/Fragment ?
?
(1)查看當前Activity ?:adb shell "dumpsys window w | grep name="
(2)查看當前棧頂的Activity :adb shell dumpsys activity | grep "mFocusedActivity"
(3)查看當前棧頂的Activity的Fragment :adb shell dumpsys activity your.package.name
也可以不用包名,而直接使用"top"選項:adb shell dumpsys activity top
CHUANCUI-MC0:~ chuancui$ adb shell dumpsys --h usage: dumpsysTo dump all services. or:dumpsys [-t TIMEOUT] [--help | -l | --skip SERVICES | SERVICE [ARGS]]--help: shows this help-l: only list services, do not dump them-t TIMEOUT: TIMEOUT to use in seconds instead of default 10 seconds--skip SERVICES: dumps all services but SERVICES (comma-separated list)SERVICE [ARGS]: dumps only service SERVICE, optionally passing ARGS to it CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ adb shell dumpsys activity -h Activity manager dump options:[-a] [-c] [-p PACKAGE] [-h] [WHAT] ...WHAT may be one of:a[ctivities]: activity stack stater[recents]: recent activities stateb[roadcasts] [PACKAGE_NAME] [history [-s]]: broadcast statebroadcast-stats [PACKAGE_NAME]: aggregated broadcast statisticsi[ntents] [PACKAGE_NAME]: pending intent statep[rocesses] [PACKAGE_NAME]: process stateo[om]: out of memory managementperm[issions]: URI permission grant stateprov[iders] [COMP_SPEC ...]: content provider stateprovider [COMP_SPEC]: provider client-side states[ervices] [COMP_SPEC ...]: service stateas[sociations]: tracked app associationssettings: currently applied config settingsservice [COMP_SPEC]: service client-side statepackage [PACKAGE_NAME]: all state related to given packageall: dump all activitiestop: dump the top activityWHAT may also be a COMP_SPEC to dump activities.COMP_SPEC may be a component name (com.foo/.myApp),a partial substring in a component name, ahex object identifier.-a: include all available server state.-c: include client state.-p: limit output to given package.--checkin: output checkin format, resetting data.--C: output checkin format, not resetting data. CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ CHUANCUI-MC0:~ chuancui$ adb shell dumpsys activity -p com.companyxxx.appxxx top?
總結
以上是生活随笔為你收集整理的Android 如何快速定位当前页面是哪个Activity or Fragment的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Things That Cannot C
- 下一篇: Fragment 与DialogFrag