0
 
            // Get a BluetoothSocket for a connection with the given BluetoothDevice 
            try { 
                if (secure) {
                    // tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE); 
                    tmp = device.createRfcommSocketToServiceRecord(UUID_SPP);
                } 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);
 
            // Always cancel discovery because it will slow down a connection 
            mAdapter.cancelDiscovery();