Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following works for me:<br> code = FlsBObg-1BQ in your case. <br> You will get lots of urls, and I choose to return the best quality.</p> <pre><code>private String getRstpLinks(String code){ String[] urls = new String[3]; String link = "http://gdata.youtube.com/feeds/api/videos/" + code + "?alt=json"; String json = getJsonString(link); // here you request from the server try { JSONObject obj = new JSONObject(json); String entry = obj.getString("entry"); JSONObject enObj = new JSONObject(entry); String group = enObj.getString("media$group"); JSONObject grObj = new JSONObject(group); String content = grObj.getString("media$content"); JSONObject cntObj = new JSONObject(group); JSONArray array = grObj.getJSONArray("media$content"); for(int j=0; j&lt;array.length(); j++){ JSONObject thumbs = array.getJSONObject(j); String url = thumbs.getString("url"); urls[j] = url; Log.d(TAG, url); //data.setThumbUrl(thumbUrl); } Log.v(TAG, content); } catch (Exception e) { Log.e(TAG, e.toString()); urls[0] = urls[1] = urls[2] = null; } return urls[2]; } </code></pre> <p>getJsonString() method.<br></p> <pre><code>public static String getJsonString(String url){ Log.e("Request URL", url); StringBuilder buffer = new StringBuilder(); HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet( url ); HttpEntity entity = null; try { HttpResponse response = client.execute(request); if( response.getStatusLine().getStatusCode() == 200 ){ entity = response.getEntity(); InputStream is = entity.getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; while( (line = br.readLine() )!= null ){ buffer.append(line); } br.close(); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ try { entity.consumeContent(); } catch (Exception e) { Log.e(TAG, "Exception = " + e.toString() ); } } return buffer.toString(); } </code></pre> <p>Don't forget to wrap it inside async task because of a network request.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload