当按下按钮时,我想在蓝牙设备中发送和接收一些数据包时运行 ProgressDialog(Spinner)。这是代码
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 操作时,我得到了进度对话框。请解释一下我可以同时获得两者的情况。谢谢你。