I am using static factory method to create fragment. But I need to use activity's context in the fragment and therefore I need to wrap that context into a bundle and attach it to the fragment using setArguements() method so that I can retrieve it later.
But if I try to store context by doing bundle.putSerializable("tag", context) -> it throws an error. Can anyone tell me how to wrap activity context into a bundle?
But I need to use activity's context in the fragment
You do not need it in most cases. All you need is to use getActivity() in your fragment instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With