I have this method which can be called from normal Activity:
getBaseContext().getResources().updateConfiguration(config2, getBaseContext().getResources().getDisplayMetrics());
The problem is I cannot call getBaseContext()
in Fragment, how can I to do that? Or with what do I need to replace the getBaseContext()
from a Fragment class?
You can use getActivity()
, which returns the activity associated with a fragment.
The activity is a context (since Activity extends Context).
But you can use it after the fragment is attached to the activity..
use getActivity().getBaseContext();
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