Code example for BluetoothDevice

Methods: createInsecureRfcommSocketToServiceRecord, createRfcommSocketToServiceRecord

0
			BluetoothSocket tmp = null;
 
			// Get a BluetoothSocket for a connection with the given BluetoothDevice 
			try { 
				if(Build.VERSION.SDK_INT >= 10) {
					tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
				} else { 
					tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
				} 
			} catch (IOException e) {
				Log.e(TAG, "create() failed", e);
			} 
			mmSocket = tmp;
		} 
 
		public void run() { 
			Log.i(TAG, "BEGIN mConnectThread");
			setName("ConnectThread");
 
			//discovery will slow down a connection 
			mAdapter.cancelDiscovery();