I would recommend reviewing these two similar qustions:
Make an HTTP request with android
How to add parameters to a HTTP GET request in Android?
UPDATE
The below code is a working sample I put together based off of the answers in the two links above; if this helps you, be sure to thank them.
For demonstration, the uri in this sample is being constructed into http://www.google.com/search?q=android.
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Construct the URI
String uri = "http://www.google.com/search?";
List<NameValuePair> params = new LinkedList<NameValuePair>();
params.add(new BasicNameValuePair("q", "android"));
uri += URLEncodedUtils.format(params, "utf-8");
// Run the HTTP request asynchronously
new RequestTask().execute(uri);
}
class RequestTask extends AsyncTask<String, String, String>{
@Override
protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
try {
response = httpclient.execute(new HttpGet(uri[0]));
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK){
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
responseString = out.toString();
} else{
//Closes the connection.
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
//TODO Handle problems..
} catch (IOException e) {
//TODO Handle problems..
}
return responseString;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
// result contains the response string.
}
}
}
And, of course, don't forget to add this to your manifest:
<uses-permission android:name="android.permission.INTERNET" />