Code example for DialogFragment

Methods: onAttach

0
        return dialog;
    } 
     
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        context = activity.getApplicationContext();
    } 
     
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        ProgressDialog dialog = new ProgressDialog(getActivity());
        dialog.setMessage(getMessage());
        dialog.setCancelable(true);
        return dialog;
    } 
     
    private String getMessage() {
        int messageId = getArguments().getInt(MESSAGE);
        return context.getResources().getString(messageId);
Connect your IDE to all the code out there  Get Codota for Java