The fact is that in every Activity there is a bodyOnResume() method that does a check.

 public void bodyOnResume(){ checkForResponseVacancy(model.getId()); } 

And I call the bodyOnResume() method inside a dialogFragment after dismiss()

 mOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); ((MainBodyActivity) getActivity()).bodyOnResume(); } }); 

This option works, but only for one MainBodyActivity , and I need to have a universal method for getting the name of the Activity that caused this dialog box.

You can try this:

 if (this.getClass().getSimpleName().equals(VacancyBodyActivity.class.toString())) { ((VacancyBodyActivity) getActivity()).bodyOnResume(); } else if(this.getClass().getSimpleName().equals(AnotherActivity.class.toString())) ((AnotherActivity) getActivity()).bodyOnResume(); } ...... // и дальше для 100500 Activity 

I tried another option:

 ((AppCompatActivity) getActivity()).bodyOnResume(); 

But here the bodyOnResume() method does not see

Question : Are there any options, how to solve this problem?

    1 answer 1

    One of the quick options

    Create an interface (as an example of OnResumeListener ) - with the bodyOnResume() method. Implement this interface into those classes where your dialog is called from.

    next just do a check when closing the dialog

     if (getActivity() instanceof OnResumeListener){ ((OnResumeListener) getActivity()).bodyOnResume(); } 

    is ready.

    • Thank you, help out! - DevOma