title: parse data from a network thread object to another object android
body: <p>I want to parse JSON object that returns from a url to a textview. for that I used class which extends AsyncTask to get the network connection. my problem is I can't parse the returning string value to my main class.</p>
  
  <p>my main class as follows</p>
  
  <pre><code>package com.example.janitha.condd;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  
  public class MainActivity extends AppCompatActivity {
  
   final String ur ="https://maps.googleapis.com/maps/api/place/textsearch/json?query=keells+super&amp;location=6.849813513872538,79.90265075223242&amp;key=AIzaSyDQ6fVTYb1_3MmD7j3Sei4CAhbZ_eIOphs";
   String outcome=null;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          TextView tv=(TextView)findViewById(R.id.text1) ;
  
          Connection con=new Connection();
          con.execute(ur);
  
         outcome =con.getFinalData();
          tv.setText(outcome);
  
   }
  }
  </code></pre>
  
  <p>my connection class as follows</p>
  
  <pre><code>package com.example.janitha.condd;
  
      import android.os.AsyncTask;
  
      import java.io.IOException;
      import java.io.InputStream;
      import java.io.InputStreamReader;
      import java.io.Reader;
      import java.io.UnsupportedEncodingException;
      import java.net.HttpURLConnection;
      import java.net.URL;
  
      /**
       * Created by Janitha on 7/10/2016.
       */
      public class Connection extends AsyncTask&lt;String, Void, String&gt; {
  
         String finalData="123";
          @Override
          protected String doInBackground(String... urls) {
  
              // params comes from the execute() call: params[0] is the url.
              try {
                  return downloadUrl(urls[0]);
              } catch (IOException e) {
                  return "Unable to retrieve web page. URL may be invalid.";
              }
          }
          // onPostExecute displays the results of the AsyncTask.
          @Override
          protected void onPostExecute(String result) {
      finalData=result;
          }
  
  
  
  
          public String downloadUrl(String myurl) throws IOException {
              InputStream is = null;
  
              int len = 50000;
  
              try {
                  URL url = new URL(myurl);
                  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                  conn.setReadTimeout(10000 /* milliseconds */);
                  conn.setConnectTimeout(15000 /* milliseconds */);
                  conn.setRequestMethod("GET");
                  conn.setDoInput(true);
                  // Starts the query
                  conn.connect();
                  int response = conn.getResponseCode();
  
                  is = conn.getInputStream();
  
                 String  contentAsString = readIt(is, len);
  
                  return contentAsString;
  
  
              } finally {
                  if (is != null) {
                      is.close();
                  }
              }
          }
          public String readIt(InputStream stream, int len) throws IOException, UnsupportedEncodingException {
              Reader reader = null;
              reader = new InputStreamReader(stream, "UTF-8");
              char[] buffer = new char[len];
              reader.read(buffer);
              return new String(buffer);
          }
  
          public String getFinalData() {
              return finalData;
          }
      }
  </code></pre>
  
  <p>each time when code executes it gives me the value as 123 which means the value that I initialized for variable finalData. what is wrong with my code?</p>