2012-09-04 6 views
0

다운로드 할 때 일시 중지를 클릭했지만 응답하지 않습니다. 구체적인 설명 방법을 모르겠다. 사실은 의미가 있지만 실제로는 깨닫지 못한다. 일시 중지를 클릭하면 다운로드 할 때 응답을 얻을 수 없습니다.

public void onClick(View v) { 

         [color=#FF0000]if (flag == 0){//click mark[/color] 

표시 할 수없는 코드는 빨간색 만 마크입니다. 코드 당신은 현재 스레드를 차단하려고

holder.btns .setOnClickListener(new OnClickListener(){ 
       @Override 
       public void onClick(View v) { 

        [color=#FF0000]if (flag == 0){//judge the click mark[/color] 

        holder.ratingBarScore.setVisibility(View.GONE); 
        holder.pro.setVisibility(View.VISIBLE); 
        holder.textView.setVisibility(View.VISIBLE); 
        if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ 
        }else { 
//      Toast.makeText(this, "there is no SD card", 1000).show(); 
         Log.v("wjp", "7889900"); 
        } 
        final String downloadUrl =(String)v.getTag(); 
        Thread thread = new Thread(){ 
         int count = 0; 
         public void run(){ 
          Log.v("ccf", "onClick"); 
          try { 
           downLoadFile(context, downloadUrl, gameName, holder);  
           openFile(context, new File("/sdcard/9twan/"+ gameName +".apk")); 
           if(!WebHelper.REGISTER_FLAG){ 
            Log.v("GamesInfoListAdapter", "WebHelper.REGISTER_FLAG == false"); 
            String imei, mac, mobile_number, model, brand; 
            boolean flag; 
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); 
            imei = tm.getDeviceId(); 
            if(imei == null){ 
             imei = "CUSTOM" + WebHelper.generateRandomIMEIString(15); 
            } 
            mac = null; 
//         mac = tm.getDeviceId(); 
            if(mac == null){ 
             mac = "CUSTOM" + WebHelper.generateRandomMacString(17); 
            } 
            mobile_number = tm.getLine1Number(); 
            model = tm.getLine1Number(); 
            brand = tm.getLine1Number(); 
            flag = WebHelper.regDevice(context, "install", imei, mac, mobile_number, model, brand); 
            if(flag){ 
             WebHelper.REGISTER_FLAG = true; 
             Log.v("GamesInfoListAdapter", "WebHelper.REGISTER_FLAG == true"); 
            } 
           } 

          }catch (Exception e){ 
           e.printStackTrace(); 
          } 
         } 
        }; 
        Log.v("wjp", "running"+thread.getName()); 
        thread.start(); 
        Toast.makeText(context, "begin to download" + gameName, 0).show(); 
        holder.btns.setBackgroundResource(R.drawable.tab_out); 

        [color=#FF0000]flag =1;[/color]//here is need to pause,how to write? 
        }else { 
          if(Thread.currentThread() !=null){ 
           Thread.interrupted(); 
//        Thread = null; 
          } 
//      thread. 
//      Thread.interrupted();//pause return boolean 
//      Thread.sleep(3000); 
//       Thread. 

         holder.btns.setBackgroundResource(R.drawable.tab_install); 
         flag =0; 

        } 
       } 

      }); 
     } 
     return convertView; 

답변

0

다음과 같이, 당신은 당신이 시작 스레드를 중단해야한다. 또한 플래그의 값을 변경하고 있습니다. 깃발이라는 여러 변수가있는 것 같습니다.

if(thread !=null){ 
thread.interrupt();  
} 
관련 문제