Android 检测用户何时退出片段

Android 检测用户何时退出片段,android,android-fragments,kotlin,fragment,Android,Android Fragments,Kotlin,Fragment,如何检测用户何时离开/退出片段?我尝试使用onStop() 我正在使用kotlin for android使用onDestroyView()或onDetach() onDestroyView() 在删除与片段关联的视图层次结构时调用 onDetach() 或者更多细节 使用onDetach()-onDestroy()或onDestroyViewonStop()在屏幕刚刚隐藏时调用,就像其他片段可见时一样。 Called when the fragment is being disassociat

如何检测用户何时离开/退出片段?我尝试使用
onStop()

我正在使用kotlin for android

使用onDestroyView()或onDetach()

onDestroyView()

在删除与片段关联的视图层次结构时调用

onDetach()

或者更多细节

使用
onDetach()
-
onDestroy()
onDestroyView
onStop()
在屏幕刚刚隐藏时调用,就像其他片段可见时一样。
Called when the fragment is being disassociated from the activity.