You would still get an NPE. The reason is, both of those methods use the mHost property of the fragment class. So if the fragment is not attached to an activity that mHost property is null. that is the reason the NPE is thrown.
Here are the method implementations;
public Context getContext() {
return mHost == null ? null : mHost.getContext();
}final public FragmentActivity getActivity() {
return mHost == null ? null : (FragmentActivity) mHost.getActivity();
}