Want to display AlertDialog in onCreate of Activity - android

后端 未结 2 782
暖寄归人
暖寄归人 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();
      }
    
    0 讨论(0)
  • 2021-01-16 18:42

    you're performing your long operations in UI thread. Move them to the AsyncTask's doInBackground method. See the example here.

    0 讨论(0)
提交回复
热议问题