Want to display AlertDialog in onCreate of Activity - android

后端 未结 2 784
暖寄归人
暖寄归人 2021-01-16 18:17

In my activity, I call a MyDialog (custom dialog) in onCreate() and handle its DismissListener in Activity to find if its cancelled or not. If its cancelled, I finish the ac

2条回答
  •  臣服心动
    2021-01-16 18:35

    To stop your dialog causing any memory leaks, ensure the following is included in your activity;

    AlertDialog _alert;
    
      @Override
      public void onPause() {
          super.onPause();
    
          if(_alert != null)
              _alert.dismiss();
      }
    

提交回复
热议问题