J2ME 中 getMajorDeviceClass 的 int 值有哪些?
Which are the int values of getMajorDeviceClass in J2ME?
我知道为了检测设备的种类,使用了DeviceClass
:
void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
我可以使用 cod.getMajorDeviceClass()
但我不知道哪些是对应于 "Computer"、"Phone"、...[= 的 int 值18=]
Major 和 Minor 值在蓝牙规范中定义。在 this page 你对值有一个全面的解释:
The Major Device Class segment is the highest level of granularity for
defining a Bluetooth device. A device's main function determines its
Major Class assignment. There are 32 major classes.
这些值在 Android 的 BluetoothClass.Device.Major 中有详细记录。例如:
public static final int COMPUTER = 0x100;
public static final int PHONE = 0x200;
您可以将这些定义复制到您的 Java ME 代码中并使用简单的比较来检查:
if (cod.getMajorDeviceClass() == COMPUTER) {
// ...
} else if (cod.getMajorDeviceClass() == PHONE) {
// ...
}
我知道为了检测设备的种类,使用了DeviceClass
:
void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
我可以使用 cod.getMajorDeviceClass()
但我不知道哪些是对应于 "Computer"、"Phone"、...[= 的 int 值18=]
Major 和 Minor 值在蓝牙规范中定义。在 this page 你对值有一个全面的解释:
The Major Device Class segment is the highest level of granularity for defining a Bluetooth device. A device's main function determines its Major Class assignment. There are 32 major classes.
这些值在 Android 的 BluetoothClass.Device.Major 中有详细记录。例如:
public static final int COMPUTER = 0x100;
public static final int PHONE = 0x200;
您可以将这些定义复制到您的 Java ME 代码中并使用简单的比较来检查:
if (cod.getMajorDeviceClass() == COMPUTER) {
// ...
} else if (cod.getMajorDeviceClass() == PHONE) {
// ...
}