Code example for DialogFragment

Methods: onCreate, setRetainInstance

0
    return dialog != null && dialog.isShowing();
  } 
 
  @Override 
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
  } 
 
  protected boolean isListenerOptional() { 
    return true; 
  } 
 
  @SuppressWarnings("unchecked") 
  @Override 
  public void onAttach(Activity activity) {
    super.onAttach(activity);
 
    try { 
      listener = (Listener) activity;
    } catch (ClassCastException e) {