run time error in android activity has been stoped
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception">android.os.NetworkOnMainThreadException</a>  </p>
</blockquote>



<p>I just built a demo application through <a href="http://www.androidhive.info/2012/01/android-json-parsing-tutorial/" rel="nofollow">this tutorial</a> and when I run the application I get the following error in log cat and the main application is stopped. Does anyone know why I am getting this error?</p>

<pre><code>05-11 15:52:06.492: E/AndroidRuntime(584): FATAL EXCEPTION: main
05-11 15:52:06.492: E/AndroidRuntime(584): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: android.os.NetworkOnMainThreadException
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.os.Looper.loop(Looper.java:137)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.ActivityThread.main(ActivityThread.java:4424)
05-11 15:52:06.492: E/AndroidRuntime(584):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 15:52:06.492: E/AndroidRuntime(584):  at java.lang.reflect.Method.invoke(Method.java:511)
05-11 15:52:06.492: E/AndroidRuntime(584):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 15:52:06.492: E/AndroidRuntime(584):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 15:52:06.492: E/AndroidRuntime(584):  at dalvik.system.NativeStart.main(Native Method)
05-11 15:52:06.492: E/AndroidRuntime(584): Caused by: android.os.NetworkOnMainThreadException
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-11 15:52:06.492: E/AndroidRuntime(584):  at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
05-11 15:52:06.492: E/AndroidRuntime(584):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
05-11 15:52:06.492: E/AndroidRuntime(584):  at java.net.InetAddress.getAllByName(InetAddress.java:220)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-11 15:52:06.492: E/AndroidRuntime(584):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-11 15:52:06.492: E/AndroidRuntime(584):  at com.androidhive.jsonparsing.JSONParser.getJSONFromUrl(JSONParser.java:38)
05-11 15:52:06.492: E/AndroidRuntime(584):  at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:54)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.Activity.performCreate(Activity.java:4465)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-11 15:52:06.492: E/AndroidRuntime(584):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-11 15:52:06.492: E/AndroidRuntime(584):  ... 11 more
</code></pre>
