Navigation Architecture Component- Passing argument data to the startDestination

前端 未结 9 788
情话喂你
情话喂你 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条回答
  •  眼角桃花
    2020-12-05 17:49

    After reading the solution i made one that suits for my needs, this solution assume that the data sent to the activity that host this graph

    on the start destination:

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        // work around get get starting destination with activity bundle
        userId = getActivity().getIntent().getIntExtra(KEY_USER_ID, -1);
    }
    

提交回复
热议问题