Note that there are some explanatory texts on larger screens.

plurals
  1. POcode not working in Jelly Beans
    primarykey
    data
    text
    <p>I have this code which returns <code>Json</code> object from url. It works fine in <code>froyo</code> but the same code is not working in <code>Jelly Beans</code>.</p> <p>Is something wrong with my code ?</p> <p>Please help me, here is my code</p> <pre><code> public static JSONObject getJSONfromURL(String url) { // initialize InputStream is = null; String result = ""; JSONObject jArray = null; // http post try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e("log_tag", "Error in http connection " + e.toString()); } // convert response to string 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(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jArray = new JSONObject(result); } catch (JSONException e) { Log.e("log_tag", "Error parsing data " + e.toString()); } return jArray; } </code></pre> <p>Here is my log error</p> <p><code>11-01 11:01:48.437: E/log_tag(1044): Error in http connection android.os.NetworkOnMainThreadException 11-01 11:01:48.437: E/log_tag(1044): Error converting result java.lang.NullPointerException 11-01 11:01:48.437: E/log_tag(1044): Error parsing data org.json.JSONException: End of input at character 0 of</code></p>
    singulars
    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.
 

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