Berikut ini Sample Post data untuk Android
HttpClient client = new DefaultHttpClient();
String postURL = "http://domainanda.com/";
HttpPost post = new HttpPost(postURL);
List params = new ArrayList();
params.add(new BasicNameValuePair("usr", "admin");
params.add(new BasicNameValuePair("pwd", "admin");
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
String datadariweb = EntityUtils.toString(resEntity).toString();
Toast.makeText(this, datadariweb, Toast.LENGTH_LONG).show();
}else{
Toast.makeText(this, "Tidak ada respon dari server", Toast.LENGTH_LONG).show();
}
0 komentar:
Post a Comment