title: Get a return value from OnPostExecute android
body: <p>First of all i have to say, i have read this:</p>
  
  <p><a href="https://stackoverflow.com/questions/17248639/how-to-get-the-return-value-from-onpostexecute-method-in-android">How to get the return value from onpostexecute method in android?</a></p>
  
  <p>And that:</p>
  
  <p><a href="https://stackoverflow.com/questions/16752073/how-do-i-return-a-boolean-from-asynctask?noredirect=1&amp;lq=1">How do I return a boolean from AsyncTask?</a></p>
  
  <p>With no help, maybe i didn't understand what they were saying.
  Here is my porblem:
  i just need to get back the String value which is in my OnPostExecute method.
  not from doInBackground, i need it from my OnPostExecute.</p>
  
  <p>My code:</p>
  
  <pre><code> public void max(String build,String cls)
  {
  
      BackgroundTask3 myTask = new BackgroundTask3();
      myTask.execute(build,cls);
  
  
      Toast.makeText(getApplicationContext(),"fcur is" + Fcur,Toast.LENGTH_LONG).show();
  
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>public class BackgroundTask3 extends AsyncTask&lt;String,Void,String&gt;
  {
  
      String capacity_url;
      @Override
      protected void onProgressUpdate(Void... values) {
          super.onProgressUpdate(values);
      }
  
      @Override
      protected void onPostExecute(String result) {
      String finalValue;
        json_capacity = result;
          finalValue=parseMax();
          Toast.makeText(getApplicationContext(),"finalValue is" + finalValue,Toast.LENGTH_LONG).show();
          super.onPostExecute(result);
  
      }
  
      @Override
      protected void onPreExecute() {
          capacity_url = "http://www.skedge.co.il/ANCurrentCapacity.php";
      }
  
      @Override
      protected String doInBackground(String... params) {
          String cls,build;
          build= params[0];
          cls = params[1];
  
          try {
              URL url = new URL (capacity_url);
              HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
              httpURLConnection.setRequestMethod("POST");
              httpURLConnection.setDoOutput(true);
              OutputStream outputStream = httpURLConnection.getOutputStream();
              BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream,"UTF-8"));
              String data_string = URLEncoder.encode("Fclass","UTF-8")+"="+URLEncoder.encode(cls,"UTF-8")+"&amp;"+
                      URLEncoder.encode("building","UTF-8")+"="+URLEncoder.encode(build,"UTF-8")+"&amp;"+
                      URLEncoder.encode("hour","UTF-8")+"="+URLEncoder.encode(hour,"UTF-8");
              bufferedWriter.write(data_string);
              bufferedWriter.flush();
              bufferedWriter.close();
              //here is the new
              InputStream inputStream = httpURLConnection.getInputStream();
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
              StringBuilder stringBuilder = new StringBuilder();
              while ((JSON_STRING = bufferedReader.readLine())!= null)
              {
                  stringBuilder.append(JSON_STRING+"\n");
              }
              outputStream.close();
              inputStream.close();
              httpURLConnection.disconnect();
              return stringBuilder.toString().trim();
  
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          return null;
  
      }
  }
  </code></pre>
  
  <p>All i want to do is:
  assign the value which is in finalValue String inside the OnPostExecute,to the Fcur (public String) which is inside to max function.</p>
  
  <p>Looks very simple but for some reason i can't get it done.</p>