2011-12-11 35 views
1

你好,我想檢測從我的電腦的外部藍牙設備的串行端口藍牙服務,爲此,我正在使用在Bluecove API和下面的代碼:無法檢測到藍牙服務(java.lang.NumberFormatException:對於輸入字符串:「0S」)

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:對於輸入字符串:‘0’」例外行:

UUID uuid = new UUID("SPP", true); 

謝謝你你的幫助

回答

0

來自bluecove的documentation

「從提供的字符串中創建一個UUID對象。字符串中的字符必須是從十六進制集[0-9,AF,AF]。」

‘SPP’是不是一個有效的十六進制數。

+0

謝謝你,我現在看到的是什麼問題,但我不知道什麼是uuid,我應該通過什麼作爲UUID構造函數的參數,所有我知道的是藍牙設備的地址。 –

相關問題