Code example for DialogFragment

Methods: getActivity, getTag

0
        return builder.create();
    } 
 
    @Override 
    public void onClick(DialogInterface dialogInterface, int i) {
        OnDialogDoneListener act = (OnDialogDoneListener) getActivity();
        boolean cancelled = false;
        if(i == AlertDialog.BUTTON_NEGATIVE){
            cancelled = true;
        } 
        act.onDialogDone(getTag(), cancelled, "Alert dismissed");
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java