What is different between getContext() and getActivity() from Fragment in support library?
Do they always return the same obje
So far, the only provided implementation of FragmentHostCallback (in the OS and the support library) always returns the same value for both getContext() and getActivity().
However, the other constructors of FragmentHostCallback suggest that in future implementations, we may get:
Activity and a non-null Context which is not an Activity. This looks improbable but we can imagine that fragments could be used outside Activities in the future, or be fully sandboxed.Activity and a non-null Context which is not the same instance as the Activity. For example, Context could be a ContextThemeWrapper.Conclusion: when you can, use getContext(). When you need Activity-specific calls, use getActivity().