Code example for BluetoothDevice

Methods: createRfcommSocketToServiceRecord

0
            // Get a BluetoothSocket for a connection with the 
            // given BluetoothDevice 
            try { 
//                Method m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class }); 
//                tmp = (BluetoothSocket) m.invoke(device, 1); 
                tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);
            } catch (Exception e) {
                e.printStackTrace();
                Log.e(TAG, "Socket Type: " + mSocketType + " create() failed", e);
            } 
            mmSocket = tmp;
        } 
 
        public void run() { 
            Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
            setName("ConnectThread" + mSocketType);
 
            // Always cancel discovery because it will slow down a connection 
            mAdapter.cancelDiscovery();
 
            // Make a connection to the BluetoothSocket