Example usage for android.bluetooth BluetoothClass getMajorDeviceClass

List of usage examples for android.bluetooth BluetoothClass getMajorDeviceClass

Introduction

In this page you can find the example usage for android.bluetooth BluetoothClass getMajorDeviceClass.

Prototype

public int getMajorDeviceClass() 

Source Link

Document

Return the major device class component of this BluetoothClass .

Usage

From source file:Main.java

/**
 * Populates the device names and the device addresses with all the suitable
 * bluetooth devices./*from   w w  w.  j  a  v a 2 s  .co m*/
 * 
 * @param bluetoothAdapter the bluetooth adapter
 * @param deviceNames list of device names
 * @param deviceAddresses list of device addresses
 */
public static void populateDeviceLists(BluetoothAdapter bluetoothAdapter, List<String> deviceNames,
        List<String> deviceAddresses) {
    // Ensure the bluetooth adapter is not in discovery mode.
    bluetoothAdapter.cancelDiscovery();

    Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
    for (BluetoothDevice device : pairedDevices) {
        BluetoothClass bluetoothClass = device.getBluetoothClass();
        if (bluetoothClass != null) {
            // Not really sure what we want, but I know what we don't want.
            switch (bluetoothClass.getMajorDeviceClass()) {
            case BluetoothClass.Device.Major.COMPUTER:
            case BluetoothClass.Device.Major.PHONE:
                break;
            default:
                deviceAddresses.add(device.getAddress());
                deviceNames.add(device.getName());
            }
        }
    }
}

From source file:org.libreoffice.impressremote.communication.BluetoothServersFinder.java

private Server.Type buildServerType(BluetoothDevice aBluetoothDevice) {
    BluetoothClass btClass = aBluetoothDevice.getBluetoothClass();
    if (null == btClass) {
        return Server.Type.UNDEFINED;
    }// w  w  w. ja  v a  2s  .c  o  m

    switch (btClass.getMajorDeviceClass()) {
    case BluetoothClass.Device.Major.COMPUTER:
        return Server.Type.COMPUTER;

    case BluetoothClass.Device.Major.PHONE:
        return Server.Type.PHONE;

    default:
        return Server.Type.UNDEFINED;
    }
}