How to get list of Bluetooth printers in Android?
Following code returns all bluetooth devices:
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
java.util.Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
Is it possible to select only printers from these devices?
UPDATE:
Device class of bluetooth class of my printer is 1664.
But I cannot find such constant in Android SDK.
Do all bluetooth printers have device class 1664?
Swipe down from the top of the screen. Touch and hold Bluetooth . If your accessory is listed under "Available media devices," next to your device's name, tap Settings . If no accessories are listed under "Previously connected devices," tap See all.
By using BluetoothAdapter method getBondedDevices(), we can get the Bluetooth paired devices list. Following is the code snippet to get all paired devices with name and MAC address of each device.
Make sure the mobile device's Bluetooth is turned on. Check to see if the printer's Bluetooth light is pulsing. If not, enable Bluetooth on the printer and try pairing with the printer again. Check if the printer is communicating with another mobile device.
This question is rather old now, but I would like to share my own experience for anyone needing this information.
You can get minor device class (getDeviceClass()
) and major (getMajorDeviceClass()
) on getBluetoothClass()
and check them against available class numbers. 1536
is a major class representing imaging devices, and printers are specified by 1664
as the minor device class.
You may also use this online device class calculator to generate the classes:
http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With