Navigation Architecture Component- Passing argument data to the startDestination

前端 未结 9 791
情话喂你
情话喂你 2020-12-05 16:43

I have an activity A that start activity B passing to it some intent data. Activity B host a navigation graph from the new Navigation Architecture Component.I want to pass t

9条回答
  •  Happy的楠姐
    2020-12-05 17:31

    It had been fixed in 1.0.0-alpha07. See detail.

    The solution is similar to Elliot Schrock's answer, but wrapping by official API.

    We have to manually inflate NavHostFragment or graph

    Use

    NavHostFragment.create(R.navigation.graph, args)
    

    Or

    navController.setGraph(R.navigation.graph, args)
    

    The args are the data we want to pass to start destination.

提交回复
热议问题