This can be resolved by confirming that current ActivityhasWindowFocus because when you get the context in the fragment, instead of exactly which Activity it is, it might not have windowFocus :
if (((Activity) mContext).hasWindowFocus()) {
mDialog.show();
}