I\'m migrating my dialogs, currently using Activity.showDialog(DIALOG_ID);
, to use the DialogFragment
system as discussed in the android reference.
There is better solution instead of using static methods and variables because it would work only fro one instance of your dialog. It is better to store your callback as non static member
private DialogTestListener mListener;
public void setListener (DialogTestListener listener){
mListener = listener;
}
Then you should show your dialog using TAG like this mDialogFragment.show(getSupportFragmentManager(), DIALOG_TAG);
And then in onResume
method of your activity you can reset your listener
protected void onResume() {
super.onResume();
mDialogFragment = (CMFilterDialogFrg) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG);
if(mDialogFragment != null){
mDialogFragment.setListener(yourListener)
}
}