Issue
The SecondActivity
only has simple layout which is set as ContentView
in its onCreate()
method:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
And the activity_second.xml
is:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondActivity" />
But when I use dumpsys
to dump the top activity, it lists an unknown Fragment
("ReportFragment") in output:
$ adb shell dumpsys activity top
TASK xxx.lifecycleapplication id=4
ACTIVITY xxx.lifecycleapplication/.SecondActivity 538274ac pid=1519
Local Activity 5368915c State:
mResumed=true mStopped=false mFinished=false
mLoadersStarted=true
mChangingConfigurations=false
mCurrentConfig={1.0 310mcc270mnc en_US sw384dp w384dp h567dp nrml port finger qwerty/v/v dpad/v s.5}
Active Fragments in 536891f0:
#0: ReportFragment{5369f99c #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
mFragmentId=#0 mContainerId=#0 mTag=androidx.lifecycle.LifecycleDispatcher.report_fragment_tag
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{536891f0 in SecondActivity{5368915c}}
mActivity=xxx.lifecycleapplication.SecondActivity@5368915c
Added Fragments:
#0: ReportFragment{5369f99c #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
FragmentManager misc state:
mCurState=5 mStateSaved=false mDestroyed=false
Local FragmentActivity 5368915c State:
mCreated=true mResumed=true mStopped=false FragmentManager misc state:
mHost=androidx.fragment.app.FragmentActivity$HostCallbacks@5368b814
mContainer=androidx.fragment.app.FragmentActivity$HostCallbacks@5368b814
mCurState=4 mStateSaved=false mStopped=false mDestroyed=false
Why output shows ReportFragment
in "Active Fragments" and "Added Fragments" while I has not use any Fragment
?
Solution
This line is the clue:
mTag=androidx.lifecycle.LifecycleDispatcher.report_fragment_tag
The ReportFragment
is an implementation detail used by the lifecycle-process
and the ProcessLifecycleOwner
for tracking whether your app has any started activity. Prior to API 29, it uses a framework Fragment for tracking this across all activities (whether they are AppCompatActivity
or regular Activity
subclasses).
Answered By - ianhanniballake
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.