마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

DB에 한번만보내면되는데 두번보냅니다.

0 추천

 public void onClick(View v) {
       
       
       dialog_board = ProgressDialog.show
        (RSS_TestActivity.this,"","Validating user...",true);
       
       new Thread(new Runnable(){
        public void run(){
         Looper.prepare();
         board_insert();
         Looper.loop();
        }
        
       }).start();
      }
     });
    }
     
    public void board_insert(){
    try{
     
     httpclient_board=new DefaultHttpClient();
     httppost_board = new HttpPost("DB주소.com");
     nameValuePairs_board = new ArrayList<NameValuePair>(4);
     nameValuePairs_board.add(new BasicNameValuePair("module_srl",module_srl.toString()));
     nameValuePairs_board.add(new BasicNameValuePair("title",write_title.getText().toString()));
     nameValuePairs_board.add(new BasicNameValuePair("nick_name",write_writer.getText().toString()));
     nameValuePairs_board.add(new BasicNameValuePair("password",write_pass.getText().toString()));
     
     httppost_board.setEntity(new UrlEncodedFormEntity(nameValuePairs_board));
     response_board=httpclient_board.execute(httppost_board);
     ResponseHandler<String> responseHandler = new BasicResponseHandler();
     final String response = httpclient_board.execute(httppost_board,responseHandler);
  
     runOnUiThread(new Runnable(){
    public void run(){
     dialog_board.dismiss();
     nameValuePairs_board.notify();
    }
   });
    
    
    
    Toast.makeText(RSS_TestActivity.this,"아아",Toast.LENGTH_SHORT ).show();
    
    finish();
    
     
    }catch(Exception e){
     dialog_board.dismiss();
     System.out.println("Exception:"+e.getMessage());
    }

 

버튼을 누르면

DB에 데이터를 보내는형태인데..

한번만보내면되는데

두번보내네요 ㅜㅜ..

쓰레드 문제인거 같긴한데..

 

무슨 문제가 있는걸까요ㅜㅜ?

 

 

젤밍 (120 포인트) 님이 2014년 11월 7일 질문

1개의 답변

0 추천

두 번 불러줬기 때문에 두 번 보내는 거네요

올려주신 소스를 보면 다음과 같은 루틴들이 있어요. 확인해 보세요

 response_board=httpclient_board.execute(httppost_board);
 
 
 final String response = httpclient_board.execute(httppost_board,responseHandler);

 

cc1232 (35,280 포인트) 님이 2014년 11월 7일 답변
...