public class ClientThread extends Thread { private BluetoothDevice device; private static String uuid = "00001601-0000-1000-8163-00805fXXXX"; public ClientThread(BluetoothDevice device){ this.device = device; } @Override public void run() { super.run(); ParcelUuid[] uid = device.getUuids(); try { BluetoothSocket socket = device.createRfcommSocketToServiceRecord(UUID.fromString(uuid)); socket.connect(); }catch (IOException e){ e.printStackTrace(); Log.e("error:","错误:", e); } } }
错误:
D/ViewRootImpl@8749aa5[MainActivity]: ViewPostIme pointer 0 D/ViewRootImpl@8749aa5[MainActivity]: ViewPostIme pointer 1 D/BluetoothUtils: isSocketAllowedBySecurityPolicy start : device null W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
不知道是什么原因??