title: HTTP request runtime error
body: <p>I am trying to make http request.</p>
  
  <p>I am using HTTP Parsing.</p>
  
  <p>Below is the code</p>
  
  <pre><code>// Creating HTTP client
  HttpClient httpClient = new DefaultHttpClient();
  
  // Creating HTTP Post
  HttpPost httpPost = new HttpPost("url");
  
  //array NameValuePair;
  // Building post parameters, key and value pair
  List&lt;NameValuePair&gt; nameValuePair = new ArrayList&lt;NameValuePair&gt;(2);
  nameValuePair.add(new BasicNameValuePair("email", "user@gmail.com"));
  nameValuePair.add(new BasicNameValuePair("id", "2222"));
  nameValuePair.add(new BasicNameValuePair("text", "text"));
  
  // Making HTTP Request
  try {
      HttpResponse response = httpClient.execute(httpPost);
  
      // writing response to log
      Log.d("Http Response:", response.toString());
  
  } catch (ClientProtocolException e) {
      // writing exception to log
      e.printStackTrace();
  
  } catch (IOException e) {
      // writing exception to log
      e.printStackTrace();
  }
  </code></pre>
  
  <p>I get runtime error. Below is the Logcat.</p>
  
  <p>It gives some Fatal Exception.</p>
  
  <pre><code>07-08 17:17:37.866: E/AndroidRuntime(26380): FATAL EXCEPTION: main
  07-08 17:17:37.866: E/AndroidRuntime(26380): android.os.NetworkOnMainThreadException
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1125)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at libcore.io.IoBridge.connectErrno(IoBridge.java:159)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at libcore.io.IoBridge.connect(IoBridge.java:112)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at java.net.Socket.connect(Socket.java:857)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at com.custom.functions.citycoupons.CustomDialog$7.onClick(CustomDialog.java:465)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.view.View.performClick(View.java:4091)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.view.View$PerformClick.run(View.java:17072)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.os.Handler.handleCallback(Handler.java:615)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.os.Handler.dispatchMessage(Handler.java:92)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.os.Looper.loop(Looper.java:153)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at android.app.ActivityThread.main(ActivityThread.java:5086)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
  07-08 17:17:37.866: E/AndroidRuntime(26380):    at dalvik.system.NativeStart.main(Native Method)
  07-08 17:17:39.336: E/Trace(26551): error opening trace file: No such file or directory (2)
  </code></pre>
  
  <p>How to fix this issue?
  Any help will be appreciated.
  Thanks in advance.</p>