안드로이드 service에서 포스트로 데이터 주고 받기 httppost 통신
public void postData() {
try {
httppost = new HttpPost(URL+"/lginsert.php?req=lgins&hpnum="+PhoneNumber+"&bcname="+bcname);
response = httpclient.execute(httppost);
bufreader = new BufferedReader(
new InputStreamReader(response.getEntity().getContent(),
"utf-8"));
line = null;
result = "";
while ((line = bufreader.readLine()) != null) {
result += line;
}
Log.d("22", result);
} catch (Exception e) {
// TODO Auto-generated catch block
}
}
//// 스레드로 접근 ////
new Thread(new Runnable() {
public void run() {
int i = 0;
while (true) {
if(httpflag){
postData();
httpflag = false;
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
}).start();