title: Error with HTTP POST Connection
body: <p>I am using a class to use HTTP POST &amp; getting data from a data base via php/json and converting it to a string.  </p>
  
  <p>The problem is that I am getting 
  <code>"Error in http connection android.os.NetworkOnMainThreadException"</code> in LogCat. I'm testing this on the emulator and I am using the correct port address.  I know this because the port works fine in other parts of the application(loading HTML from Localhost). If I run the php file in a desktop browser, it runs fine.  I also know that the permissions are set correctly in mySQL for 10.0.2.2 &amp; the user set in the php login file.</p>
  
  <p>So my question is: Has anyone come accross the same issue and if so, have you figured out what the problem was or any ideas for what else I should look for?</p>
  
  <p>Thnx for your help!</p>
  
  <pre><code>public void loadQuery(String p) {
  
          String qO = getIntent().getStringExtra("QUERY_ORDER");
  
          ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
          // http post
          try {
              HttpClient httpclient = new DefaultHttpClient();
              // HttpPost httppost = new HttpPost("http://10.0.2.2/Andaero/php/" +
              // p + qO + ".php");
  
              //Hard coded the php link to make sure --&gt;
  
              HttpPost httppost = new HttpPost(
                      "http://10.0.2.2/Andaero/php/regulatory_list_ASC.php");
  
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
          } catch (Exception e) {
              Log.e("log_tag", "Error in http connection " + e.toString());
          }
  
          // convert response to string
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              sb = new StringBuilder();
              sb.append(reader.readLine() + "\n");
  
              String line = "0";
              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());
          }
  
          setListAdapter(new QueryAdapter(this, result));
      }
  </code></pre>