我有一个程序,一旦我收到来自我的网络服务的结果,我想通过蓝牙向设备发送命令:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case DEVICE_FOUND:
if (resultCode == Activity.RESULT_OK && data != null) {
String deviceAddress = data.getStringExtra(BluetoothDevice.EXTRA_DEVICE);
Log.d("nRFUART", "... onActivityResultdevice.address==" + deviceAddress);
((TextView) findViewById(R.id.txtState)).setText("Device found - configuration in process....");
//activate a bluetooth connectivity to lock.
if (mService.connect(deviceAddress)){
Log.d("mService", " mService connected true");
};
//do a web service call for some values
String rResult = "";
WebServiceCallIO wsio = new WebServiceCallIO();
try {
rResult = wsio.execute(sURL + "ws/locki", deviceAddress, Id, null, rResult).get();
if (rResult == "") {
showMessage("Invalid request");
}else{
btnTest.setEnabled(true);
instructDevice(rResult);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
default:
Log.e(“DeviceActivity", "wrong request code");
break;
}
}
问题是,如果我让应用程序运行,当我来到线路时会收到错误" instructDevice(rResult);"。如果我在调试模式下运行,请在" btnTest.setEnabled(true);"设置断点,应用程序按原样运行。
我通过线
检查了与设备的连接if (mService.connect(deviceAddress)){
Log.d("mService", " mService connected true");
};
并通过日志显示在我尝试指示设备之前系统日志服务已连接。
有人可以解释这段代码的错误吗?
谢谢!