Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Parse Image from JSON url in Android?
    text
    copied!<p><img src="https://i.stack.imgur.com/nHvRe.jpg" alt="Image"></p> <p>I'm parsing this content from Wordpress blog. I don't know how to get Images from <code>JSON</code>. This is the image url <code>"content":"&lt;p&gt;&lt;img class=\"aligncenter\" style=\"cursor: -moz-zoom-in;\" src=\"http:\/\/sphotos-h.ak.fbcdn.net\/hphotos-ak-ash4\/395050_10151219612828815_5123523_n.jpg\" alt=\"http:\/\/sphotos-h.ak.fbcdn.net\/hphotos-ak-ash4\/395050_10151219612828815_5123523_n.jpg\" width=\"390\" height=\"466\" \/&gt;&lt;\/p&gt;\n&lt;p&gt;&lt;span id=\"more-5267\"&gt;&lt;\/span&gt;&lt;\/p&gt;\n&lt;p&gt;Some texts here...XXXXXYYYYYZZZZ"</code></p> <pre><code>HttpClient client; HttpGet get; HttpResponse res; HttpEntity ent; Button b; TextView tv1,tv2,tv3; @TargetApi(Build.VERSION_CODES.GINGERBREAD) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Typeface tp=Typeface.createFromAsset(getAssets(), "AftaSansThin-Regular.otf"); StrictMode.enableDefaults(); b = (Button) findViewById(R.id.button1); tv1 = (TextView) findViewById(R.id.textView1); tv2 = (TextView) findViewById(R.id.textView2); tv3 = (TextView) findViewById(R.id.textView3); tv1.setTypeface(tp); tv2.setTypeface(tp); tv3.setTypeface(tp); client = new DefaultHttpClient(); get = new HttpGet("http://example.com"); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { res=client.execute(get); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ent=res.getEntity(); InputStream is = null; try { is=ent.getContent(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } BufferedReader br = new BufferedReader(new InputStreamReader(is)); StringBuffer sb = new StringBuffer(); String line = null; do{ try { line = br.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } sb.append(line); } while (line!=null); String str = sb.toString(); try { JSONObject ob1 = new JSONObject(str); JSONObject ob2 = ob1.getJSONObject("post"); String title = ob2.getString("title"); String date = ob2.getString("date"); String content = ob2.getString("content"); tv1.setText(title); tv2.setText(date); Spanned marked_up = Html.fromHtml(content); tv3.setText(marked_up.toString(),BufferType.SPANNABLE); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } </code></pre>
 

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