Android device Bluetooth connection scan gun how to get the scan content
Editor to share with you the Android device Bluetooth connection scan gun how to get the scan content, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Bluetooth pairing
Open the system settings, Bluetooth paired scanning gun, the general scanning gun instructions are written, after the pairing is completed, it shows that it is connected
Configure permissions in 2.AndroidManifest
Configure the permissions required for a Bluetooth connection in
3. Get device information and determine whether it is connected or not
Here the device type returned by the Bluetooth device is BluetoothClass.Device.Major.PERIPHERAL
/ * whether the scanning gun is connected to * @ return * / public boolean hasScanGun () {if (mBluetoothAdapter = = null) {return false;} Set blueDevices = mBluetoothAdapter.getBondedDevices (); if (blueDevices = = null | | blueDevices.size () = KeyEvent.KEYCODE_A & & keyCode = KeyEvent.KEYCODE_0 & & keyCode