androidfragmentdumpsys

Get info of current visible fragment(s) in android dumpsys


I'm looking a solution to determine which fragments are currently visible from dumpsys

I can get info about activities

$ adb shell dumpsys activity | grep -i run

Is there any solution for fragments or how do you determine visible fragments from dumpsys?


Solution

  • Check documentation with adb shell dumpsys activity -h. You can provide a <COMP_SPEC> parameter, adb shell dumpsys activity <COMP_SPEC>. When you give the <COMP_SPEC> parameter, you get more information on the specific component, including the visible fragments and views.

    Example when Android device settings are displayed:

    $ adb shell dumpsys activity com.android.settings
    

    On my device, the command output contains:

    ...
    Active Fragments in 13c3a270:
      #0: DashboardSummary{186a79e9 #0 id=0x7f0e017b}
        mFragmentId=#7f0e017b mContainerId=#7f0e017b mTag=null
        mState=5 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
        mAdded=true mRemoving=false mResumed=true mFromLayout=false mInLayout=false
        mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
        mRetainInstance=false mRetaining=false mUserVisibleHint=true
        mFragmentManager=FragmentManager{13c3a270 in Settings{ef6d7d6}}
        mActivity=com.android.settings.Settings@ef6d7d6
        mContainer=android.widget.FrameLayout{9b1166e V.E..... ........ 0,0-768,1022 #7f0e017b app:id/main_content}
        mView=android.widget.ScrollView{1c50410f VFED.V.. ........ 0,0-768,1022 #7f0e005a app:id/dashboard}
        Child FragmentManager{2298759c in DashboardSummary{186a79e9}}:
          FragmentManager misc state:
            mActivity=com.android.settings.Settings@ef6d7d6
            mContainer=android.app.Fragment$1@167cba5
            mParent=DashboardSummary{186a79e9 #0 id=0x7f0e017b}
            mCurState=5 mStateSaved=false mDestroyed=false
    ...