title: Using AsyncTasnk and return value and compare with other value
body: <p>I want to return a value from <code>AsyncTask</code> and I want to compare with the value <code>contents</code> and at the and if they match I want to send the value where I take it from <code>AsyncTasnk</code> to the other intent. I hope I explained it properly.</p>
  
  <p>and this is the code :</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      Button ButtonClick;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final TextView txt = (TextView) findViewById(R.id.textView1);
          ButtonClick = (Button) findViewById(R.id.qrReader);
          ButtonClick.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(
                          "com.google.zxing.client.android.SCAN");
                  startActivityForResult(intent, 0);
                  MainActivity.this.runOnUiThread(new Runnable() {
  
                      public void run() {
                          GetProduts GP = new GetProduts();
                          txt.setText(GP.execute().toString());
                      }
  
                  });
                  // Intent i = new Intent(MainActivity.this,IndexActivity.class);
                  // startActivity(i);
  
              }
          });
  
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode,
              Intent intent) {
  
          if (requestCode == 0) {
              if (resultCode == RESULT_OK) {
                  final String contents = intent.getStringExtra("SCAN_RESULT");
                  //I want to compare this value
  
              }
          } else if (resultCode == RESULT_CANCELED) {
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      public class GetProduts extends AsyncTask&lt;ArrayList&lt;Product&gt;, Void, ArrayList&lt;Product&gt;&gt; {
  
          Product p;
          final ArrayList&lt;Product&gt; productIdList = new ArrayList&lt;Product&gt;();
  
          @Override
          protected ArrayList&lt;Product&gt; doInBackground(ArrayList&lt;Product&gt;... params) {
              HttpClient httpclient = new DefaultHttpClient();
              GeneralConstans GC = new GeneralConstans();
              // Products will be stated in memory
              HttpPost httpget = new HttpPost(GC.UrlProducts);
              HttpResponse response;
              String result = null;
              try {
  
                  HttpContext ctx = new BasicHttpContext();
  
                  List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(
                          2);
                  httpget.setEntity(new UrlEncodedFormEntity(nameValuePairs,
                          "UTF-8"));
  
                  response = httpclient.execute(httpget, ctx);
                  HttpEntity resEntity = response.getEntity();
  
                  if (resEntity != null) {
                      result = EntityUtils.toString(resEntity);
                      JSONArray arr = new JSONArray(result);
                      Gson gson = new Gson();
                      if (arr.length() &gt; 0) {
                          for (int j = 0; j &lt; arr.length(); j++) {
                              p = gson.fromJson(arr.getString(j), Product.class);
                              productIdList.add(p);
                          }
  
                      }
  
                      return productIdList;
  
                  }
  
              } catch (ClientProtocolException e) {
                  e.printStackTrace();
              } catch (SocketException e) {
                  /*
                   * if (checkAbortStatus(e.getMessage()) == true) {
                   * handler.sendEmptyMessage(0); }
                   */
              } catch (IOException e) {
                  /*
                   * if (checkAbortStatus(e.getMessage()) == true) {
                   * handler.sendEmptyMessage(0); }
                   */
                  e.printStackTrace();
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(ArrayList&lt;Product&gt; result) {
  
  
              super.onPostExecute(result);
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
          }
  
      }
  }
  </code></pre>