No, not the way you are doing it, because the dialog only exists once clicked. If however you move the declaration to a member variable, yes (as below)
public class MyFragment extends Fragment {
private MyDialog dialog;
@Override
public View onCreateView(...) {
...
dialogTrigger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View src) {
dialog = new MyDialog(src.getContext());
dialog.show();
}
});
...
protected MyDialog getDialog() {
return dialog.
}
}
public class MyActivity extends FragmentActivity {
public void doIt(View src) {
//TODO: seems you want to do this too (?): dialogTrigger.callOnClick();
//EDIT: oops i missed the following the first time
MyDialog dialog = ((MyFragment)getSupportFragmentManager().findFragmentById(R.id.my_fragment)).getDialog()
....
}
There are better ways to handle such a situation though