title: Letting AsyncTask have a List<NameValuePair> as Parameter
body: <p>I want to send data to my server in form of <code>JSON</code>. Firstly, It worked well but now I had to change the class to use <code>AsyncTask</code> to do some networking operations because I have faced the <code>android.os.NetworkOnMainThreadException</code> problem, and the solution is to use <code>AsyncTask</code>. However, I encountered a problem that the constructor <code>UrlEncodedFormEntity(List&lt;NameValuePair&gt;[])</code> is undefined. So, what should I change in this class?</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>public class JSONParser extends AsyncTask&lt;List&lt;NameValuePair&gt;, Void, String&gt; {
  private static String registerURL = "http://sit-edu4.sit.kmutt.ac.th/csc498/53270327/Boss/sftrip/index.php/register";
  static InputStream is = null;
  static JSONObject jObj = null;
  static String json = "";
  
  protected String doInBackground(List&lt;NameValuePair&gt;... params) {
      DefaultHttpClient httpClient = new DefaultHttpClient();
      HttpPost httpPost = new HttpPost(registerURL);
      // Making HTTP request
      try {
          // defaultHttpClient
  
          httpPost.setEntity(new UrlEncodedFormEntity(params));
  
          HttpResponse httpResponse = httpClient.execute(httpPost);
          StatusLine statusLine = httpResponse.getStatusLine();
          int statusCode = statusLine.getStatusCode();
          if (statusCode == 200) {
              HttpEntity httpEntity = httpResponse.getEntity();
              is = httpEntity.getContent();
          } else {
              Log.e("Log", "Failed to download result..");
          }
  
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      } catch (ClientProtocolException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      try {
          if (is != null) {
          BufferedReader reader = new BufferedReader(new InputStreamReader(
                  is, "iso-8859-1"), 8);
          StringBuilder sb = new StringBuilder();
          String line = null;
          while ((line = reader.readLine()) != null) {
              sb.append(line + "\n");
          }
          is.close();
          json = sb.toString();
          Log.e("JSON", json);
          } else {
              Log.e("Log", "Something wrong with IS");
          }
      } catch (Exception e) {
          Log.e("Buffer Error", "Error converting result " + e.toString());
      }
      return json;
  }
  </code></pre>
  
  <p>}</p>