getActivity()
is null
. You are probably calling this method before your activity is attached to your fragment.
From the documentation:
Caution: If you need a Context object within your Fragment, you cancall getActivity(). However, be careful to call getActivity() onlywhen the fragment is attached to an activity. When the fragment is notyet attached, or was detached during the end of its lifecycle,getActivity() will return null
Try and understand the fragment lifecycle and how it is coupled with activity lifecycle.