java.lang.IllegalArgumentException:重新创建Activity时,此NavController未知导航目的地{actionId}吗? [英] java.lang.IllegalArgumentException: navigation destination {actionId} is unknown to this NavController when Activity is recreated?
问题描述
我来自阅读 IllegalArgumentException中的所有答案:该NavController未知导航目的地xxx ,但运气不佳.从手动recreate()调用重新创建活动或从流程终止返回活动时,我得到了这个提示.
I am coming from reading all the answers in IllegalArgumentException: navigation destination xxx is unknown to this NavController with no luck. I am getting this when the activity is recreated from either a manual recreate() call or coming back from a process death.
我有一个 Activity
,可以使用 Navigation
更改其 Fragments
.片段A具有一个FAB,单击该FAB即可导航到片段B.
I have an Activity
that changes its Fragments
using Navigation
.
Fragment A has a FAB that navigates to Fragment B when clicked.
floatingActionButton = view.findViewById<FloatingActionButton>(R.id.floating_action_button).apply {
setOnClickListener {
findNavController().navigate(R.id.action_fragmentA_to_fragmentB,
null,
null,
FragmentNavigatorExtras(this to "shared_element_container"))
}
}
工作正常,但是在重新创建活动后单击FAB时,我会崩溃.
Works fine but when the FAB is clicked after the activity is recreated I get a crash.
推荐答案
结果是我不小心给嵌套图和片段赋予了相同的ID.
Turns out I had accidentally given the same id to a nested graph and a fragment.
这篇关于java.lang.IllegalArgumentException:重新创建Activity时,此NavController未知导航目的地{actionId}吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!