Setting a static variable of a particular activity is not advisable as this adds a dependency in your fragment. Fragments are supposed to be isolated and should be cohesive. So that it can be used by any activity.
Better way would be to have an interface DialogAction:
interface DialogAction{
void onDialogAction(String option);
}
Let your activity implement this and write an implementation of the onDialogAction
void onDialogAction(String option){
//set an instance variable
}
and in DialogFragment declare an object of DialogAction:
private DialogAction listener;
public void setListener(DialogAction listener){
this.listener=listener;
}
now on action just call
listener.onDialogAction(options[which]);
Don't forget to set Listener in you activity on fragment.
inside activity when you create new fragment also call:
fragment.setListener(this);//'this' here the is a reference to the Activity implementing DialogAction