Why getContext() in fragment sometimes returns null?
As the accepted answer says, you must look into the way you are using and caching context. Somehow you are leaking context that is causing Null Pointer Exception. Below Answer is as per the first revision of the question. Use onAttach() to get Context. Most of the cases, you don’t need this solution so use … Read more