한화면에 버튼이 3개있습니다.
이벤트가 다 WEB 서버로 접속해서 SELECT, INSERT, UPDATE 하는 버튼인데.
각 버튼 이벤트 마다
httpclient = new DefaultHttpClient();
TelephonyManager telmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
telnum = telmgr.getLine1Number();
ArrayList arraylist = new ArrayList();
arraylist.add(new BasicNameValuePair("param", telnum));
HttpParams httpparams = httpclient.getParams();
HttpPost httppost = new HttpPost(
"http://");
UrlEncodedFormEntity urlencodedformentity = new UrlEncodedFormEntity(
arraylist, "utf-8");
httppost.setEntity(urlencodedformentity);
HttpResponse httpresponse = httpclient.execute(httppost);
HttpEntity httpentity = httpresponse.getEntity();
InputStream inputstream = httpentity.getContent();
BufferedReader bufferedreader = new BufferedReader(
new InputStreamReader(inputstream, "utf-8"));
String line = "";
while ((line = bufferedreader.readLine()) != null) {
result += line + "\n";
}
이런식으로 HTTP 객체 생성해서 개발을 해야하나요?
아니면 한번만 WEB서버에 접속하고 나머지 2개의 버튼 이벤트일때는 위와같은 코드를 전부 코딩 안해도 되는지요. ㅠ
3개의 버튼 이벤트 마다 이렇게 하는건 쫌 무식한 방법인거 같아서요...
아니면. WEB서버에 접속 하는 이부분만. class 파일로 만들어서 각 버튼이벤트 할때마다 객체 생성해서 하는 방법도 되는지요.




각각 접속해야 합니다.
HTTP 프로토콜은 한번 요청하고 응답이 오면 바로 접속이 끊어집니다.