title: android: how to show ProgressDialogFragment in MainActivity
body: <p>I got some problem on code below, when i build the app it show error at the MainActivity side. Below is the code:
  ProgressDialogFragment.java</p>
  
  <pre><code>public class ProgressDialogFragment extends DialogFragment
  {
  
      public static ProgressDialogFragment newInstance() {
          ProgressDialogFragment frag = new ProgressDialogFragment ();
          return frag;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setCancelable(false);
      }
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState)
      {
          ProgressDialog dialog = new ProgressDialog(getActivity(), getTheme());
          dialog.setTitle(getString(R.string.updatename_loading_title));
          dialog.setMessage(getString(R.string.updatename_loading_message));
          dialog.setIndeterminate(true);
          dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
          return dialog;
      }
  
  }
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>public void doPositiveClick(DialogFragment dialog) {
                  Dialog dialogView = dialog.getDialog();
                  EditText editName = (EditText) dialogView.findViewById(R.id.editName);
                  String updateName = editName.getText().toString().trim();
                      login.setName(updateName);
                      new HttpAsyncTask().execute(uNameUrl);
                      dialogView.dismiss();
              }
  
          private class HttpAsyncTask extends AsyncTask&lt;String, Void, String&gt; {
  
                  @Override
                  protected void onPreExecute() {
                      super.onPreExecute();
                     progressDialog.show(MainActivity.getFragmentManager(),"loading");
                  }
  
                  @Override
                  protected String doInBackground(String... urls) {
  
                      // Do Action Here
                  }
      }
  </code></pre>
  
  <p>I want to show loading after submit, but got error at line below:</p>
  
  <pre><code>progressDialog.show(MainActivity.getFragmentManager(),"loading"); 
  </code></pre>
  
  <p>Error Message below show after i build the app.</p>
  
  <pre><code>Error:(216, 45) error: non-static method getFragmentManager() cannot be referenced from a static context
  </code></pre>
  
  <p>How can i fix this?
  Thanks</p>
  
  <p>@Edit
  I fixed the first error, i just forgot to add this on ProgressDialogFragment.java </p>
  
  <pre><code>@Override
      public void show(FragmentManager manager, String tag) {
          if (manager.findFragmentByTag(tag) == null) {
              super.show(manager, tag);
          }
      }
  </code></pre>
  
  <p>for prevent duplicate dialog when rotate the mobile.
  Now it got second error</p>
  
  <pre><code>Error:(40, 5) error: method does not override or implement a method from a supertype
  Error:(43, 18) error: no suitable method found for show(android.app.FragmentManager,String)
          method DialogFragment.show(android.support.v4.app.FragmentManager,String) is not applicable
          (argument mismatch; android.app.FragmentManager cannot be converted to android.support.v4.app.FragmentManager)
          method DialogFragment.show(FragmentTransaction,String) is not applicable
          (argument mismatch; android.app.FragmentManager cannot be converted to FragmentTransaction)
  </code></pre>