The constructor AlertDialog.Builder expects a Context parameter. Context is accessible from Activity, Service etc, since they all extendContext, and can be passed as this.
The method getActivity() is declared as others have mentiond in the Fragment class.