title: android problem with progress dialog
body: <p>In my app i m trying to fetch data from server and storing in database.
  When it is doing all these work i want at that time progressdialog should show, if successfully data fetches then dialog should close and some alertDialog should show for msg "successfully data fetched". and if any n/w problem there, then it should show different msg that "problem with n/w".</p>
  
  <p>for that i am doing like below,</p>
  
  <pre><code>public void onClick(View arg0) {
                  myProgressDialog = ProgressDialog.show(
                          getParent(), "Please wait...",
                          "Doing upgrade...", true);
                  new Thread() {
                      public void run() {
                          try {
  
                          upgradeAll();//function where data fetched from server
  
                              sleep(5000);
  
                          } catch (Exception e) {
                          }
                          // Dismiss the Dialog
  
                          myProgressDialog.dismiss();
  
  
                          Toast.makeText(UpgradeAllTableData.this, "Due to some internal problem \n" +
                                  "it couldnot update..", Toast.LENGTH_LONG).show();
                      }
  
                  }.start();
              }
  </code></pre>
  
  <p>AsyncTask code,</p>
  
  <pre><code>private class UpgradeTask extends AsyncTask&lt;Context, Void, Void&gt; {
          private ProgressDialog Dialog = new ProgressDialog(UpgradeAllTableData.this);
  
          @Override
          protected void onPreExecute() {
              System.out.println("In onPreExecute ");
              Dialog.setTitle("Loading");
              Dialog.setMessage("Please wait for few seconds...");
              Dialog.show();
          }
  
          @Override
          protected Void doInBackground(Context... params) {
              System.out.println("In doInBackground ");
  
              upgradeAll();
  
              System.out.println("In doInBackground after fetching");
              return null;
          }
  
          @Override
            protected void onPostExecute(Void unused) {
  
              System.out.println("In onPostExecute ");
              Dialog.dismiss();
  
              Toast.makeText(UpgradeAllTableData.this, "Problem with internet" ,  Toast.LENGTH_SHORT).show();
              alertboxNeutral("Warning", "Problem with Internet Connection", "Okay","Try again");
  
          }
      }
  </code></pre>
  
  <p>Problem is Toast is not showing. why?</p>
  
  <p>My question is which condition and where to give so that if any problem with n/w then it show some msg and success then show another msg. </p>
  
  <p>Where i should write code for that?
  Give me some suggestion.</p>
  
  <p>Thank you</p>