Page 448 - MDP2020-3
P. 448
442
| 인천전자마이스터고등학교 ·············································································································
private class GetData extends AsyncTask<String, Void, String>{
ProgressDialog progressDialog;
@Override
protected void onPreExecute(){
super.onPreExecute();
p r o g r e s s D i a l o g = P r o g r e s s D i a l o g . s h o w ( R e s u l t _ o f f . t h i s , " P l e a s e
Wait",null,true,true);
}
@Override
protected void onPostExecute(String result){
super.onPostExecute(result);
progressDialog.dismiss();
if (result==null){
} else {
mJsonString=result;
showResult();
}
}
@Override
protected String doInBackground(String... params){
try {
String mode=(String)params[0];
String serverURL="http://192.168.102.83/MDP/score_off.php";
String data = URLEncoder.encode("mode", "UTF-8") + "=" +
URLEncoder.encode(mode, "UTF-8");
URL url = new URL(serverURL);
HttpURLConnection httpURLConnection = (HttpURLConnection)
url.openConnection();
httpURLConnection.setReadTimeout(5000);
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
OutputStreamWriter wr = new
OutputStreamWriter(httpURLConnection.getOutputStream());
wr.write(data);
wr.flush();
int responseStatusCode = httpURLConnection.getResponseCode();
InputStream inputStream;
if (responseStatusCode == HttpURLConnection.HTTP_OK) {
inputStream = httpURLConnection.getInputStream();