1

我想在按下按钮时在蓝牙设备中发送和接收一些数据包时运行ProgressDialog(微调)。这里是代码在Android中的线程中运行ProgressDialog

button.setOnClickListener(new OnClickListener() { 

      public void onClick(View v) { 


      Handler handler = new Handler(); 
      Runnable r=new Runnable() 
      { 
       public void run() 
       { 
        dialog1 = ProgressDialog.show(Test.this, "", 
          "Receiving. Please wait...", true); 



       } 
      }; 
      handler.post(r); 

      blueToothServer.getDevicebyMac(); 
      blueToothServer.rfSocket(); 
      blueToothServer.cancelDiscovery(); 
      blueToothServer.connectSocket(); 
      //toastMessage("Socket connected"); 
      blueToothServer.ipstream(); 
      blueToothServer.opStream(); 
      blueToothServer.SendnRXDataToBTServer(2, "some String"); 
      String Result1 = blueToothServer.response(1); 
      tv1.setText("Temperatue : " + Result1); 
      dialog1.dismiss(); 
} 

但我没有得到ProgressDialog。但是我可以发送和接收数据包。但是当我评论blueToothServer操作时,我会看到进度对话框。请解释我可以得到的情况。谢谢。

回答

相关问题