Page 450 - MDP2020-3
P. 450

444
                      |    인천전자마이스터고등학교  ·············································································································

                    class  InsertData  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();

                                    Toast.makeText(getApplicationContext(),   "점수가            저장됐습니다.",
            Toast.LENGTH_SHORT).show();
                                    finish();
                            }
                            @Override

                            protected  String  doInBackground(String...  params){
                                    try  {
                                            String  score=(String)params[0];
                                            String  mode=(String)params[1];
                                            String  serverURL="http://192.168.102.83/MDP/input_score.php";

                                            String  data  =  "&"  +  URLEncoder.encode("score",  "UTF-8")  +  "="  +
            URLEncoder.encode(score,  "UTF-8");
                                            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)  {
   445   446   447   448   449   450   451   452   453   454   455