title: ProgressDailog in asynctask from another Activity
body: <p>I Have two <code>Activity</code>. The MainActivity is calling the another <code>Activity</code> which extends <code>AsyncTask</code>. In <code>AsyncTask</code> i had display <code>ProgressDailog</code> <code>onPreExecute()</code>, but <code>ProgressDailog</code> is not been display. The reason may be <code>AyncTask</code> execute for less time but the response but response takes time and therefore <code>ProgressDialog</code> should be displayed.</p>
  
  <p>The Following code is provide. </p>
  
  <p><strong>Aysnc class</strong></p>
  
  <pre><code> public class NewConnections extends AsyncTask&lt;Void,Void,String&gt;{
  
          Context context;
          String[] name,value;
          String Geturl,para;
          ProgressDialog progressDialog;
  
          NewConnections(Context context,String[] name,String[] value,String Url){
              this.context = context;
              this.name = name;
              this.value = value;
              Geturl = Url;
          }
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              progressDialog = new ProgressDialog(context);
              progressDialog.setMessage("Please Wait");
              progressDialog.show();
          }
          @Override
          protected String doInBackground(Void... voids) {
              try
              {
                  para = DCBUtil.jsonCovertion(name,value);
                  URL url = new URL(Geturl);
  
                  String responseStr = XXX.callJsonHttp(url,para);
                  System.out.println("Response of Home Open FD :: "+responseStr);
  
                  return responseStr;
  
              }catch(Exception e)
              {
                  return "Error";
              }
          }
          @Override
          protected void onPostExecute(String s) {
              super.onPostExecute(s);
              progressDialog.dismiss();
  
          }
      }
  </code></pre>
  
  <p><strong>MainClass</strong></p>
  
  <pre><code>public class FirstPage extends AppCompatActivity {
  
      Button existUser,newUser;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_first_page);
  
          existUser = (Button)findViewById(R.id.existUser);
          newUser = (Button)findViewById(R.id.newUser);
  
          newUser.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  String[] value = {"asdasd"};
                  String[] name = {"dprm"};
  
                  try {
                      NewConnections v= new NewConnections(FirstPage.this,name,value,"url is provided");
                      v.execute().get();
  
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });
  </code></pre>