- 작성시간 : 2012/02/09 17:15
- 퍼머링크 : jjunda.egloos.com/5081822
- 덧글수 : 0
http를 통해서 정보를 읽어올려고하는데..
서버가 종료되어있을때 빠져나와야하기때문에..
timeout걸고.. 아무런 응답이 없으면 null을 리턴한다..
HttpClient client = null;
public ScheduleApi(Context c) {
// TODO Auto-generated constructor stub
mContext = c;
final HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
final SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 7001));
final ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, registry);
client = new DefaultHttpClient(manager, params);
client.getParams().setParameter("http.protocol.expect-continue", false);
client.getParams().setParameter("http.connection.timeout", 3000);
client.getParams().setParameter("http.socket.timeout", 3000);
}
public String check_schedule_dt(){
String responseString = null;
try{
String requestStr = String.format(http://wwww 파일주소..");
HttpGet getMethod = new HttpGet(requestStr);
HttpResponse response = client.execute(getMethod);
HttpEntity resEntity = response.getEntity();
if(resEntity != null){
return EntityUtils.toString(resEntity);
}else
return null;
}catch(Exception t){
}
return null;
}



최근 덧글