title: How to change Show/Remove Dialog and onPrepareDialog for DialogFragments
body: <p>I'm working on an Android project. I need to use Android 1.6 or above. </p>
  
  <p>My project was working, but now it is showing me some warnings about Dialogs like </p>
  
  <pre><code>"The method dismissDialog(int) from the type Activity is deprecated"
  "The method showDialog(int) from the type Activity is deprecated", etc.
  </code></pre>
  
  <p>So I want to "update" my project to solve these warnings.</p>
  
  <p>I have read and made some test projects to learn about Fragments and DialogFragment.
  I have created my own ProgressDialog and I want to use it on my real project, but I have some problems.</p>
  
  <pre><code>public class MyProgressDialog extends DialogFragment {
  
  public MyProgressDialog(){
  
  }
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
  
      Context context = getActivity();
  
      ProgressDialog dialog = new ProgressDialog(context);
  
      Resources resources = context.getResources();
  
          String message = resources.getText(R.string.wait).toString();
  
      dialog.setMessage(message);
      dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  
      return dialog;
      }
  }
  </code></pre>
  
  <p>Earlier in my project, I created the <code>ProgressDialog</code> and then, in <code>onPrepareDialog()</code> method, I called an <code>AsyncTask</code> to connect the server, downloaded the data, etc. Then in <code>onPostExecute</code> of the AsyncTask, I dismissed the <code>ProgressDialog</code> and started the new Activity. But now I can't do that because <code>onPrepareDialog</code> is deprecated.</p>
  
  <p><strong>Calling ActionAsyncTask on onPrepareDialog of Activy</strong></p>
  
  <pre><code>@Override
  protected void onPrepareDialog(int id, Dialog dialog) {     
      switch(id){
  
          case Constants.PROGRESS_DIALOG:
                                      new ActionAsyncTask().execute();
                                      break;
      }
  }
  </code></pre>
  
  <p><strong>onPostExecute of ActionAsyncTask</strong></p>
  
  <pre><code>@Override
  protected void onPostExecute(Integer result) {
      dismissDialog(Constants.PROGRESS_DIALOG);
  }
  </code></pre>
  
  <p>How can solve this? What is the right way to do this? I want to write the best code for this, the most efficient code.</p>
  
  <p>Thanks.</p>