title: Pass parameter using HTTP GET in Android
body: <p>in one of my views in my application I have ListView which displays data from MySQL database using a Listadapter, JSON,PHP etc. All of that works, but what I'm trying to figure out (with no success) is how could I send a parameter to PHP so then I can retrieve not all the profiles(in case of my application) but instead the ones I want depending on user id.</p>
  
  <p><strong>This is the AsynTask code that make the HTTP</strong>:</p>
  
  <pre><code>private class GetProfiles extends AsyncTask&lt;String, Void, String&gt;{
  
      private ProgressDialog pDialog;
      private String message;
      private final GetProfilesListener listener;
  
      /**
       * Method to set listener value.
       */
      public GetProfiles(GetProfilesListener listener){
          this.listener = listener;
      }
  
      protected void onPreExecute(){
          super.onPreExecute();
  
          pDialog = new ProgressDialog(UserProfiles.this);
          pDialog.setTitle("Contacting Server");
          pDialog.setMessage("Loading profile(s)...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(true);
          pDialog.show();
      }
  
      @Override
      protected String doInBackground(String... params) {
          if (params == null ) 
              return null;
  
          String url = params[0];
  
           try {
                  // create http connection
                  HttpClient client = new DefaultHttpClient();
                  HttpGet httpget = new HttpGet(url);
  
                  // connect
                  HttpResponse response = client.execute(httpget);
  
                  // get response
                  HttpEntity entity = response.getEntity();
  
                  if(entity == null) {
                      message = "No response from server";
                      return null;        
                  }
  
                  // get response content and convert it to json string
                  InputStream is = entity.getContent();
                  return streamToString(is);
              }
              catch(IOException e){
                  message = "No Network Connection";
              }
  
           return null;
      }
  
  
        @Override
          protected void onPostExecute(String sJson) {
              if(sJson == null) {
                  if(listener != null) listener.onFetchFailure(message);
                  return;
              }        
  
              try {
                  // convert json string to json array
                  JSONArray aJson = new JSONArray(sJson);
                  // create profiles list
                  List&lt;Profiles&gt; profiles = new ArrayList&lt;Profiles&gt;();
  
                  for(int i=0; i&lt;aJson.length(); i++) {
                      JSONObject json = aJson.getJSONObject(i);
                      Profiles pro = new Profiles();
                      pro.setProfileName(json.getString("profilename"));
                      pro.setPetType(json.getString("pettype"));
                      pro.setUsername(json.getString("username"));
                      pro.setProfileid(Integer.parseInt(json.getString("profileid")));
  
                      pDialog.dismiss();
  
                      // add profile to profiles list
                      profiles.add(pro);
  
                  }
  
                  //notify the activity that fetch data has been complete
                  if(listener != null) listener.onFetchComplete(profiles);
              } catch (JSONException e) {
                  message = "Invalid response";
                  if(listener != null) listener.onFetchFailure(message);
                  return;
              }        
          }
  </code></pre>
  
  <p>I know that one of my parameters is the url where it says <code>String url = param[0]</code> I just don't know how to add another parameter into the code which would be used in the server side to retrieve information depending on id or name etc. I tried to build parameters like this: </p>
  
  <pre><code>List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
                  params.add(new BasicNameValuePair(TAG_AID, adid));
  </code></pre>
  
  <p>But it didn't allow me.</p>