I now need to keep the status when I return, so I write as follows:
@AndroidEntryPoint
class IndexFragment : Fragment() {
private var rootView: View? = null
private var isFirstLoad = true
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
if (isFirstLoad) {
initView()
}
return rootView
}
private fun initView() {
binding = FragmentIndexBinding.inflate(layoutInflater)
rootView = binding?.root
}
}
I'm a novice android. Leakcanary will report the rootView memory leak problem.I don't know whether this is a false alarm of Leakcanary or a real memory leak. I added a shared element transition and a page in a nested fragment. In addition, I can't think of how to keep the state when the previous page returns.