0

I am tiring this for sometime now to send response from server to android & havent been successful so far... code:

   try{
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://10.0.2.2:80/php/base.php");
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        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());
       } 

    StringBuilder sb;
     try{
      BufferedReader reader = new BufferedReader(new
       InputStreamReader(is,"iso-8859-1"),8);
        sb = new StringBuilder();
          sb.append(reader.readLine() + "\n");
       String line = null;
       while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
        }
       text = sb.toString();
        tv.setText(text);
         is.close();
        }

Cant figure out whats wrong....i cant get response on android emulator ...its just an echo statement on the script...how can i output it on the device.I have tried json too didnt work

prade
  • 43
  • 5
  • Make sure you have the internet permission as described [here](http://stackoverflow.com/questions/2378607/what-permission-do-i-need-to-access-internet-from-an-android-application). – Matt Briançon May 15 '11 at 15:50

1 Answers1

0

you needn't to specify port no. in URL .try with this url "http://10.0.2.2/php/base.php"

Neha Mangla
  • 1,042
  • 3
  • 13
  • 24