android 로그인 처리 예제
public void doLogin(String uri, String username, String password) {
List
nvps.add(new BasicNameValuePair("username", username));
nvps.add(new BasicNameValuePair("password", password));
HttpClient client = new DefaultHttpClient();
HttpPost httpost = new HttpPost(PROTOCOL_PREFIX + uri);
try {
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
// Post, check and show the result (not really
spectacular, but works):
client.execute(httpost, new BasicResponseHandler() {
@Override
public String handleResponse(HttpResponse response) {
HttpEntity entity = response.getEntity();
HttpParams params = response.getParams();
Log.i("LOGIN", "e: " + entity + " p: " + params);
return "";
}
});
} catch (Exception e) {
Log.e(getClass().getName(), "Error logging in: " +
e.getMessage(),
e);
}
}
[출처] 안드로이드 로그인 처리|작성자 프레드