您好,我想从我的计算机检测外部蓝牙设备的串行端口蓝牙服务,为此我使用 Bluecove API 和以下代码:
BluetoothDeviceDiscovery bluetoothDeviceDiscovery=new BluetoothDeviceDiscovery();
//display local device address and name
LocalDevice localDevice = LocalDevice.getLocalDevice();
System.out.println("Address: "+localDevice.getBluetoothAddress());
System.out.println("Name: "+localDevice.getFriendlyName());
//find devices
DiscoveryAgent agent = localDevice.getDiscoveryAgent();
UUID uuid = new UUID("SPP", true);
String ServiceURL = agent.selectService(uuid,ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);//"btspp://localhost:"+rd.getBluetoothAddress()+";name=SPP";
if( ServiceURL == null) {
System.out.println("Connection failed: "+ uuid +"\n");
return;
}
但我在行中始终出现“java.lang.NumberFormatException:对于输入字符串:“0S””异常:
UUID uuid = new UUID("SPP", true);
感谢您的帮助
最佳答案
关于java - 无法检测到蓝牙服务(java.lang.NumberFormatException : For input string: "0S" ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8465270/