title: How to parse YOUTUBE JSON in JAVA & show in a list View
body: <p>How Can I parse JSON YouTube data API v3 in JAVA?</p>
  
  <p><a href="https://www.googleapis.com/youtube/v3/search?part=snippet&amp;maxResult=30&amp;q=natok%20bangla%20mosharrof%20karim&amp;key=AIzaSyCR40QlsuX0aFfBV-wEPDsH_jxna1tDFRA" rel="nofollow">here is my json data</a></p>
  
  <p>I want to show the data in a list view &amp; after clicking a video will be played.
  How can i do this?
      public class MainActivity extends ListActivity {</p>
  
  <pre><code>private ProgressDialog pDialog;
  
  // URL to get contacts JSON
  private static String url = "https://www.googleapis.com/youtube/v3/search?part=snippet&amp;maxResult=30&amp;q=natok+bangla+mosharrof+karim&amp;key=AIzaSyCR40QlsuX0aFfBV-wEPDsH_jxna1tDFRA";
  
  private static final String TAG_ITEMS = "items";
  private static final String TAG_ID = "id";
  private static final String TAG_ID_VIDEOID = "videoId";
  private static final String TAG_TITLE = "title";
  private static final String TAG_DESCRIPTION = "description";
  private static final String TAG_THUMBANAILS_URL = "https://i.ytimg.com/vi/hlaX2OZ_kDg/default.jpg";
  private static final String TAG_CHANNELTITLE = "channelTitle";
  
  JSONArray items = null;
  
  // Hashmap for ListView
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; itemsList;
  
  ListView lv = getListView();
  
  // Hashmap for ListView
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; itemslist;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      itemslist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      ListView lv = getListView();
  
      lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                  int position, long id) {
              // getting values from selected ListItem
              String name = ((TextView) view.findViewById(R.id.name))
                      .getText().toString();
              String cost = ((TextView) view.findViewById(R.id.email))
                      .getText().toString();
              String description = ((TextView) view.findViewById(R.id.mobile))
                      .getText().toString();
  
              // Starting single contact activity
              Intent in = new Intent(getApplicationContext(),
                      SingleContactActivity.class);
              in.putExtra(TAG_ID, name);
              in.putExtra(TAG_TITLE, cost);
              in.putExtra(TAG_DESCRIPTION, description);
              startActivity(in);
  
          }
      });
  
      new GetContacts().execute();
  }
  private class GetContacts extends AsyncTask&lt;Void, Void, Void&gt; {
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          // Showing progress dialog
          pDialog = new ProgressDialog(MainActivity.this);
          pDialog.setMessage("Please wait...");
          pDialog.setCancelable(false);
          pDialog.show();
  
      }
  
      @Override
      protected Void doInBackground(Void... arg0) {
          // Creating service handler class instance
          ServiceHandler sh = new ServiceHandler();
  
          // Making a request to url and getting response
          String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
          Log.d("Response: ", "&gt; " + jsonStr);
  
          if (jsonStr != null) {
              try {
                  JSONObject jsonObj = new JSONObject(jsonStr);
  
                  // Getting JSON Array node
                  items = jsonObj.getJSONArray(TAG_ITEMS);
  
                  // looping through All Contacts
                  for (int i = 0; i &lt; items.length(); i++) {
                      JSONObject c = items.getJSONObject(i);
  
                      String id = c.getString(TAG_ID);
                      String videoId = c.getString(TAG_ID_VIDEOID);
                      String channelTitle = c.getString(TAG_CHANNELTITLE);
  
                      // tmp hashmap for single contact
                      HashMap&lt;String, String&gt; contact = new HashMap&lt;String, String&gt;();
  
                      // adding each child node to HashMap key =&gt; value
                      contact.put(TAG_ID, id);
                      contact.put(TAG_ID_VIDEOID, videoId);
                      contact.put(TAG_CHANNELTITLE, channelTitle);
  
  
                      // adding contact to contact list
                      itemsList.add(contact);
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          } else {
              Log.e("ServiceHandler", "Couldn't get any data from the url");
          }
  
          return null;
      }
      @Override
      protected void onPostExecute(Void result) {
          super.onPostExecute(result);
          // Dismiss the progress dialog
          if (pDialog.isShowing())
              pDialog.dismiss();
          /**
           * Updating parsed JSON data into ListView
           * */
          ListAdapter adapter = new SimpleAdapter(
                  MainActivity.this, itemsList,R.layout.list_item, new String[] { TAG_TITLE, TAG_DESCRIPTION,
                  TAG_CHANNELTITLE }, new int[] { R.id.name,
                  R.id.email, R.id.mobile });
  
          setListAdapter(adapter);
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>here is my java code</p>