Code example for BluetoothSocket

Methods: getInputStream, isConnected

0
            InputStream mmInStream = null;
            // Get a BluetoothSocket for a connection with the 
            // given BluetoothDevice 
            try { 
            	tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);// UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
            	 b1 = tmp.isConnected();
               if(b1)
            	   mmInStream  = tmp.getInputStream();
            } 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();