title: Why I am getting android.os.NetworkOnMainThreadException with AsyncTask?
body: <p>I am getting android.os.NetworkOnMainThreadException while I have wrote the code of networking operation in AsynkTask. is there any other reason for throwing this exception?</p>
  
  <p><strong>Here is my Code:</strong></p>
  
  <pre><code>public class Background_confirmation extends AsyncTask&lt;Void, Integer, Void&gt; {
          @Override
          protected void onPreExecute() {
              // TODO Auto-generated method stub
              progressDialog = ProgressDialog.show(Confirmation.this,
                      "Please wait...", "Retrieving data ...", true);
              try {
                  HttpClient httpclient = new DefaultHttpClient();
  
                  HttpPost httppost = new HttpPost(
                          "http://68.121.167.160/sip_chat_api/create_account.php?useralias="
                                  + useralias + "&amp;cntname=" + cntcode + "");
                  HttpResponse response = httpclient.execute(httppost);
                  HttpEntity entity = response.getEntity();
                      is = entity.getContent();
  
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
              if (backgroung_flag == 1) {
  
              } else {
                  if (is != null) {
                      try {
                          BufferedReader reader = new BufferedReader(
                                  new InputStreamReader(is, "UTF-8"));
                          StringBuilder sb = new StringBuilder();
                          String line = null;
                          while ((line = reader.readLine()) != null) {
                              sb.append(line + "\n");
                          }
                          is.close();
  
                          result = sb.toString();
                      } catch (Exception e) {
                          Log.e("log_tag",
                                  "Error converting result " + e.toString());
                      }
                  }
  
              }
              super.onPreExecute();
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              // TODO Auto-generated method stub
  
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              // TODO Auto-generated method stub
              if (progressDialog.isShowing()) {
                  progressDialog.dismiss();
                  // progressDialog.setCancelable(true);
              }
              super.onPostExecute(result);
          }
  
      }
  </code></pre>
  
  <p>And i am calling this class in OnCreate()</p>
  
  <pre><code>new Background_confirmation().execute();
  </code></pre>
  
  <p>But it always goes in Catch block and gives me <a href="http://pastie.org/4601772" rel="noreferrer">this</a> exceptions <a href="http://pastie.org/4601772" rel="noreferrer">LogCat</a><br>
  Any suggestion and idea will be Appreciated.<br>
  Thanks</p>