0
我有我的應用程序控制使用藍牙的國內設備,其中我的應用程序將連接並需要與我的HC-05藍牙模塊配對,但問題是當我編碼的東西除了20:13:06:19:34:00這個HC-05藍牙模塊的MAC地址之外的其他MAC地址,它會捕獲所有的藍牙設備,包括我的HC-05,其中我特別包含了它的MAC地址。Trapping在我的應用程序中的特定MAC地址失敗
因此,這裏是我的陷阱MAC地址的一部分:
case REQUEST_DEVICE_CONNECT:
String HC05 = "4C:0F:6E:0F:12:F4";
// When DeviceList Activity returns with a device to connect
if (resultCode == Activity.RESULT_OK) {
// Get the device MAC address
//String address = data.getExtras().getString(DeviceList.EXTRA_DEVICE_MAC_ADDRESS);
String address = new String(data.getExtras().getString(DeviceList.EXTRA_DEVICE_MAC_ADDRESS));
if (address == HC05)
{
// Get the BLuetoothDevice object
BluetoothDevice device = BTAdapter.getRemoteDevice(address);
// Attempt to connect to the device
commandService.connect(device);
}
else if (address != HC05)
{
Toast.makeText(this, "This device is not for JavaC101 Application. Please connect to HC-05 device.", Toast.LENGTH_LONG).show();
}
}
break;
我已經嘗試了一些其他的可能性,但我還是很具有此功能的衰竭。無論如何,它是我第一次創建一個android應用程序。任何幫助將非常感激。謝謝。
太謝謝你了!現在起作用了。 :)) – itsJane