There is a class:

public class MyDatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener //Создадим объект календарь @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Log.d(Constants.LOG_TAG, "MyDatePickerFragment - onCreateDialog - Создадим объект календарь"); // определяем текущую дату Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // создаем DatePickerDialog и возвращаем его Dialog picker = new DatePickerDialog(getActivity(), this, year, month, day); picker.setTitle(R.string.choose_date); return picker; } @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { } 

I do a call like this:

public void changeDate (View view){ Log.d(Constants.LOG_TAG, "ChangeTask - changeDate - Метод изменения даты"); //вызываем диалог и заносим результат в текстВью MyDatePickerFragment dateDialog = new MyDatePickerFragment(); dateDialog.show(getFragmentManager(), "ChangeTask"); }

As I understand the second parameter in the show method is the TAG - identifier. There is a need to call the same dialogue in another Activity .

How to check where the call came from?

As I understand it somehow you need to pull out the TAG in the onDateSet method, but how?

    1 answer 1

    It can be different. If the task is reduced to the definition of which action is started - you can call getActivity() instanceof SOME_ACTIVITY_CLASS_NAME in the dialog - this is how you define activations.

    You can also pass a set of info through arguments when starting a dialog. Use Bundle and Fragment#setArguments(Bundle args) .

    If you want to call a dialog from the fragment, FragmentDialog#setTargetFragment(Fragment fr, int requestCode) will help you. More here