title: Android - displaying alert dialog during doinbackground while catching exception
body: <p>I have this code and it goes to catch as soon as it hits <code>Source.httpConn</code> and it sends the exception down below to catch.</p>
  
  <pre><code>         try
              {
              JSONTokener sbTokener = new JSONTokener(Source.httpConn(infoUrlStr, Main.this).toString());
              //array için hazırlandı
  
              JSONArray jArray=new JSONArray(sbTokener);
              //arraye eklendi
              for(int i=0; i&lt;(jArray.length()); i++)
      .
      .
      .
       }
  </code></pre>
  
  <p>Down in the catch part there is my alert dialog method. It normally works pretty well but I suspect that I have the problem because of the <code>doInBackground</code>. The application crashes before displaying the below alert dialog. All the try-catch is in my <code>doInBackground</code> method in <code>ASyncTask</code>.</p>
  
  <pre><code>                 catch (Exception e) {
                          AlertDialogDisp(Main.this, noServ, noServLog);
                      }
  </code></pre>
  
  <p>How can I make my application NOT crash and just display this alert dialog and then return to my Main activity as it was. Here is my alert dialog method:</p>
  
  <pre><code>      protected void AlertDialogDisp(Context dialogContext, String head, String log) {
  
  
      new AlertDialog.Builder(dialogContext)
      .setTitle(head)
      .setMessage(log)
      .setPositiveButton("okay", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) { 
              // On Alert Dialog Button
              dialog.dismiss();
          }
      })
  
      .show();
  }
  </code></pre>