Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* @author Nesswit, Heewon Lee
- * 이 소스 코드는 현재 사용중인 다른 프로젝트의 일부분을 가져온 것입니다.
- * 따라서 이 코드만으로는 완전히 동작하지 않습니다.
- */
- /**
- * HTTP GET 전송
- * @param url 목적 URL
- * @param params 함께 보낼 파라미터
- *
- * @return Response String
- */
- public String httpRequestGet(final String url, final ArrayList<BasicNameValuePair> params) {
- //반환할 Response String
- String result = null;
- /*
- * Callable을 통해 비동기적으로 처리
- */
- //Callable 선언
- Callable<String> getCallable = new Callable<String>() {
- @Override
- public String call() throws Exception {
- String ent = URLEncodedUtils.format(params, HTTP.UTF_8);
- HttpGet get = new HttpGet(url + "?" + ent);
- HttpResponse response = null;
- try {
- response = getClient().execute(get);
- } catch (Exception e) {}
- HttpEntity resEntity = response.getEntity();
- String res = null;
- try {
- res = EntityUtils.toString(resEntity);
- } catch (Exception e) {}
- return res;
- }
- };
- //Callable 시작
- Future<String> postFuture = es.submit(getCallable);
- try {
- //결과값 반환
- //R.integer.http_timeout_second 만큼 기다림.
- result = postFuture.get(GlobalConstants.getHttpTimeoutSeconds(), TimeUnit.SECONDS);
- } catch (Exception e) {}
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment