Note that there are some explanatory texts on larger screens.

plurals
  1. POError in connecting localhost
    primarykey
    data
    text
    <p>I know this question has been asked for several times, but I am helpless now.</p> <p>I have a php webpage at localhost that echo "Hello". (working perfect at localhost). I have following code that displays response from localhost web page to TextView in my app.</p> <pre><code>tv = (TextView) findViewById(R.id.txtTest); InputStream is = null; String result = ""; String url = "http://10.0.2.2/android/try.php"; HttpClient httpclient = new DefaultHttpClient(); try { HttpPost httppost = new HttpPost(url); HttpResponse response = httpclient.execute(httppost); Log.d("myapp", "response " + response.getEntity()); HttpEntity entity = response.getEntity(); is = entity.getContent(); String st = EntityUtils.toString(response.getEntity()); } 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, "UTF-8"), 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()); } tv.setText(result.toString()); </code></pre> <p>I am getting following error (LogCat).</p> <pre><code>09-24 13:34:42.654: E/log_tag(2032): Error in http connection android.os.NetworkOnMainThreadException 09-24 13:34:42.654: E/log_tag(2032): Error converting result java.lang.NullPointerException </code></pre> <p><strong>P.S</strong> I have added Internet permission in Manifest. </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. 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