I am doing an e-commerce app, do I need to pass the AUTH information like id from Login activity -> Home Fragment -> product activity -> product details (when user add to favor list it will be based on the user id, add to firebase which is sub-collection under user list)
I try to pass the data from Login activity -> HomeFragement -> product ->details ->account
can I do like this getExtra from then put extra to(it will be like a middle man to pass data between them):
var docIDAuth = requireActivity().intent.getStringExtra("docIDFromLoginAuth")
var intent = Intent(requireActivity(), ProductDetails::class.java)
intent.putExtra("docIDFromLoginAuth", docIDAuth)
startActivity(intent)
or call it to pass to multiple activities/fragment in one times
var docIDAuth = requireActivity().intent.getStringExtra("docIDFromLoginAuth")
var intent = Intent(requireActivity(), Login::class.java)
intent.putExtra("docIDFromLoginAuth", docIDAuth)
startActivity(intent)
var intent = Intent(requireActivity(), HomeFragment::class.java)
intent.putExtra("docIDFromLoginAuth", docIDAuth)
startActivity(intent)
var intent = Intent(requireActivity(), Prodcut::class.java)
intent.putExtra("docIDFromLoginAuth", docIDAuth)
startActivity(intent)
var intent = Intent(requireActivity(), ProductDetails::class.java)
intent.putExtra("docIDFromLoginAuth", docIDAuth)
startActivity(intent)
or should I use interface or ViewModel to do it?
Can u show the sample code to tell me how to implement it. I am new to this.