MainActivity has leaked window 
<p>I am new to Android, I have started only 7 days ago. I'm getting this type of error and also refer most of the topic in the same forum, asked for similar question, but not getting how to resolve. </p>

<p>Here is my code:</p>

<pre><code>class CreateNewCustomer extends AsyncTask&lt;String, String, String&gt; {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity4.this);
pDialog.setMessage("Creating Customer..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

protected String doInBackground(String... args) {
String fname = inputFName.getText().toString();
String lname = inputLName.getText().toString();
String phone = inputPhone.getText().toString();

List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
params.add(new BasicNameValuePair("fname", fname));
params.add(new BasicNameValuePair("lname", lname));
params.add(new BasicNameValuePair("phone", phone));
JSONObject json = jsonParser.makeHttpRequest(url_create_customer,
                    "POST", params);
Log.d("Create Response", json.toString());

try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Intent i = new Intent(getApplicationContext(),MainActivity5.class);
startActivity(i);
finish();
} else {
// This is the Else part
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}

protected void onPostExecute(String file_url) {
pDialog.dismiss();
}

}
</code></pre>
