Code example for BluetoothDevice

Methods: createInsecureRfcommSocketToServiceRecord, createRfcommSocketToServiceRecord

0
 
            // Get a BluetoothSocket for a connection with the 
            // given BluetoothDevice 
            try { 
                if (secure) {
                    tmp = device.createRfcommSocketToServiceRecord(
                            MY_UUID_SECURE);
                } else { 
                    tmp = device.createInsecureRfcommSocketToServiceRecord(
                            MY_UUID_INSECURE);
                } 
            } catch (IOException e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
            } 
            mmSocket = tmp;
        } 
 
        public void run() { 
            Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
            setName("ConnectThread" + mSocketType);