假设我们有两个片段:MainFragment和SelectionFragment.第二个是用于选择某个对象的构建,例如整数.从第二个片段接收结果有不同的方法,如回调,总线等.
现在,如果我们决定使用导航架构组件导航到第二个片段,我们可以使用以下代码:
NavHostFragment.findNavController(this).navigate(R.id.action_selection, bundle)
Run Code Online (Sandbox Code Playgroud)
其中bundle是Bundle(当然)的实例.正如您所看到的那样,无法访问SelectionFragment我们可以进行回调的位置.问题是,如何使用Navigation Architecture Component接收结果?
android android-architecture-components android-jetpack android-architecture-navigation