title: How do I print PHP echo on my android app?
body: <p>I'm fairly new to android and PHP programming and I am currently running into a problem printing my echo statement from my php page, which is as simple as:</p>
  
  <pre><code>    &lt;?php
      echo "Hey there response!";
      ?&gt;
  </code></pre>
  
  <p>What I am currently using in my MainActivity is:</p>
  
  <pre><code>        setContentView(R.layout.activity_main);
  
      TextView txtView = (TextView) findViewById(R.id.txt);
  
      //ASYNC WAY
      new GetData(txtView).execute("");
  </code></pre>
  
  <p>Where AsyncTask is defined by:</p>
  
  <pre><code>private class GetData extends AsyncTask&lt;String, Void, String&gt;{
      private TextView display;
  
  
      GetData(TextView view){
          this.display = view;
          display = (TextView) findViewById(R.id.txt);
      }
  
      protected String doInBackground(String... message){
          HttpClient httpclient;
          HttpGet request;
          HttpResponse response = null;
          String result = "error0";
          try{
              httpclient = new DefaultHttpClient();
              request = new HttpGet("http://localhost/php/wamp.php");
              response = httpclient.execute(request);
          } catch (Exception e){
              result = "error1";
          }
  
          try{
              BufferedReader rd = new BufferedReader(new InputStreamReader(
                      response.getEntity().getContent()));
              String line="";
              while((line = rd.readLine()) != null){
                  result = result + line;
              }
          } catch(Exception e){
              result = "error2";
          }
          return result;
      }
  
      protected void onPostExecute(String result){
          this.display.setText(result);
      }
  }
  </code></pre>
  
  <p>The message in the txtView becomes error2, and I have no idea why.</p>
  
  <p><strong>EDIT</strong>
  I was originally using a non-AsyncTask method of reading in input stream but I have switch to AsyncTask due to Networking error. The problem still persists though since I am not getting the corrent echo in my application.</p>