title: Android anonymous asyncTask return value in method
body: <p>Now in my app i try to do http parsing from url, but i didn't carry about threads, before this time...</p>
  
  <p>I have such class and method:</p>
  
  <pre><code>public class TwitterOAuthHelper {
  public String httpQueryToApi(String url) {
          HttpGet get = new HttpGet(url);
          HttpParams params = new BasicHttpParams();
          HttpProtocolParams.setUseExpectContinue(params, false);
          get.setParams(params);
          String response = null;
          try {
              SharedPreferences settings = context.getSharedPreferences("my_app", 0);
              String userKey = settings.getString("user_key", "");
              String userSecret = settings.getString("user_secret", "");
              consumer.setTokenWithSecret(userKey, userSecret);
              consumer.sign(get);
              DefaultHttpClient client = new DefaultHttpClient();
              response = client.execute(get, new BasicResponseHandler());
          } catch (Exception e) {
              displayToast("Failed to get data.");
          }
          return response;
      }
  
  }
  </code></pre>
  
  <p>and now i try to move this logic into asyncTask:</p>
  
  <pre><code>String result;
  public String httpQueryToApi(String url) {
      new AsyncTask&lt;String,Void,String&gt;(){
  
          @Override
          protected String doInBackground(String... params) {
              HttpGet get = new HttpGet(String.valueOf(params));
              HttpParams param = new BasicHttpParams();
              HttpProtocolParams.setUseExpectContinue(param, false);
              get.setParams(param);
              String response = null;
              try {
                  SharedPreferences settings = context.getSharedPreferences("my_app", 0);
                  String userKey = settings.getString("user_key", "");
                  String userSecret = settings.getString("user_secret", "");
                  consumer.setTokenWithSecret(userKey, userSecret);
                  consumer.sign(get);
                  DefaultHttpClient client = new DefaultHttpClient();
                  response = client.execute(get, new BasicResponseHandler());
              } catch (Exception e) {
                  displayToast("Failed to get data.");
              }
              result = response;
              return response;
          }
      }.execute(url);
      return result;
      }
  </code></pre>
  
  <p>but how can i return my response result value to method?</p>
  
  <p>what is the best practice of doing that?</p>