title: I want to display values on textview through JSONParser using given url
body: <p>I want to display about_builder of given <code>JSON</code> url, but I am not able to declare properly <code>JSONObject</code> and <code>JSONArray</code> on <code>MainActivity</code>, so please anyone help me to display the data on <code>TextView</code>. 
  Error shown: </p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.example.and_ws_builder/com.example.and_ws_builder.MainActivity}:
    android.os.NetworkOnMainThreadException</p>
  </blockquote>
  
  <p>MainActivity.java class</p>
  
  <pre><code> public class MainActivity extends Activity {   
          private static String url ="http://myfourwalls.in/services_microsite/project_builder.php";
          private static final String TAG_Name = "about_builder";
          JSONArray builder = null;
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
              JSONParser jParser = new JSONParser();        
              JSONObject json = jParser.getJSONFormUrl(url);        
              try {
  
                  builder = json.getJSONArray(TAG_Name);
                   JSONObject c = builder.getJSONObject(0);
  
                  for (int i = 0; i &lt; json.length(); i++) {
  
                      String name = c.getString(TAG_Name);                
                      final TextView nam = (TextView) findViewById(R.id.txtname);
                      nam.setText(name);
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      }
  </code></pre>
  
  <p>JSONParser.java</p>
  
  <pre><code>public class JSONParser {
       static InputStream is = null;
       static JSONObject jobj = null;
       static String json = "";
      public JSONParser() {
      }
  
      public JSONObject getJSONFormUrl(String url) {  
          try {
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpPost httpPost = new HttpPost(url);
              HttpResponse httpResponse = httpClient.execute(httpPost);
              HttpEntity httpEntity = httpResponse.getEntity();
              is = httpEntity.getContent();
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          }catch (ClientProtocolException e) {
              e.printStackTrace();
          }catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null ){
                  sb.append(line +"\n");
              }
              is.close();
              json = sb.toString();
  
          } catch (Exception e) {
               Log.e("Buffer Error","Error converting result" + e.toString());
          }
          try {
              jobj = new JSONObject(json);
  
          } catch (JSONException e) {
              Log.e("JSON Parse","error Parsing data" + e.toString());
          }
          return jobj;
      }
  }
  </code></pre>
  
  <p>main_activity.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;    
       &lt;TextView 
           android:id="@+id/txtname"
           android:layout_width="fill_parent"
           android:layout_height="100dp"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>