Code example for DialogFragment

Methods: onCreateDialog, getActivity

    public Dialog onCreateDialog(Bundle savedInstanceState) {
        if (null != savedInstanceState) {
            mCalendar = (Calendar) savedInstanceState.getSerializable(CALENDAR);
        if (null == mCalendar) {
            mCalendar = Calendar.getInstance();
        int year = mCalendar.get(Calendar.YEAR);
        int month = mCalendar.get(Calendar.MONTH);
        int day = mCalendar.get(Calendar.DAY_OF_MONTH);
        // Create a new instance of DatePickerDialog and return it 
        return new DatePickerDialog(getActivity(), this, year, month, day);
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
        mCallback.onDateSet(view, year, monthOfYear, dayOfMonth);
Connect your IDE to all the code out there  Get Codota for Java