Navigation Architecture Component- Passing argument data to the startDestination

OK, I found a solution to that problem thanks to Ian Lake from the Google team.
Let say you have an activity A that will start activity B with some intent data and you want to get that data in the startDestination you have two options here if you using safe args which is my case you could do

StartFragmentArgs.fromBundle(requireActivity().intent?.extras)

to read the args from the Intent. If you don’t use safe args you can extract the data from the bundle your self-using requireActivity().intent?.extras which will return a Bundle you can use instead of the fragment getArguments() method. That’s it I try it and everything works fine.

Leave a Comment