Issue
I am creating an app for a school assignment where I need to use 2 activities, which both have a navGraph with multiple fragments.
I know how to pass data between the fragments, but I need to pass data from the userActivity to the mainActivity using safeArgs.
I need to pass the userId from the userFragment to the mainFragment
I haven't been able to find any information on this, could someone help me out?
Solution
You need to pass the args from UserFragment
to MainActivity
first, then extract the args inside your MainFragment
using MainFragmentArgs.fromBundle(requireActivity().intent.extras)
. For details check out this simple repository I just created that implements your requirements.
https://github.com/phamtdat/MultipleNavGraphDemo
Answered By - Dat Pham Tat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.