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 { 
 
					// check version of android to use different code for 
					// calling BT connection 
					int currentapiVersion = android.os.Build.VERSION.SDK_INT;
					if (currentapiVersion > android.os.Build.VERSION_CODES.GINGERBREAD) {
						// Do something for anything above gingerbread 
						tmp = device
								.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE);
					} else { 
						// do something for phones running an SDK before 
						// Gingerbread MR1 
 
					}