为什么 "dumpsys activity top" 在它的输出中列出 "fragment" 而我没有使用片段?
Why does "dumpsys activity top" list "fragment" in its output while I did not use fragment?
SecondActivity
只有简单的布局,在其onCreate()
方法中设置为ContentView
:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
而 activity_second.xml
是:
<?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" />
但是当我使用dumpsys
转储顶部activity时,它在输出中列出了一个未知的Fragment
("ReportFragment"):
$ 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
为什么在 "Active Fragments" 和 "Added Fragments" 中输出显示 ReportFragment
而我没有使用任何 Fragment
?
这一行就是线索:
mTag=androidx.lifecycle.LifecycleDispatcher.report_fragment_tag
ReportFragment
is an implementation detail used by the lifecycle-process
and the ProcessLifecycleOwner
用于跟踪您的应用是否已启动 activity。在 API 29 之前,它使用框架片段来跟踪所有活动(无论它们是 AppCompatActivity
还是常规 Activity
子类)。
SecondActivity
只有简单的布局,在其onCreate()
方法中设置为ContentView
:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
而 activity_second.xml
是:
<?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" />
但是当我使用dumpsys
转储顶部activity时,它在输出中列出了一个未知的Fragment
("ReportFragment"):
$ 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
为什么在 "Active Fragments" 和 "Added Fragments" 中输出显示 ReportFragment
而我没有使用任何 Fragment
?
这一行就是线索:
mTag=androidx.lifecycle.LifecycleDispatcher.report_fragment_tag
ReportFragment
is an implementation detail used by the lifecycle-process
and the ProcessLifecycleOwner
用于跟踪您的应用是否已启动 activity。在 API 29 之前,它使用框架片段来跟踪所有活动(无论它们是 AppCompatActivity
还是常规 Activity
子类)。