public final class BluetoothClass implements Parcelable{
public static class Device {
private static final int BITMASK = 0x1FFC;
* Defines all major device class constants.
* <p>See {@link BluetoothClass.Device} for minor classes.
public static class Major {
private static final int BITMASK = 0x1F00;//比特掩码
public static final int MISC = 0x0000;//麦克风
public static final int COMPUTER = 0x0100;//电脑
public static final int PHONE = 0x0200;//电话
public static final int NETWORKING = 0x0300;//网络
public static final int AUDIO_VIDEO = 0x0400;//音频
public static final int PERIPHERAL = 0x0500;//外部设备
public static final int IMAGING = 0x0600;//镜像,映像
public static final int WEARABLE = 0x0700;//穿戴设备
public static final int TOY = 0x0800;//玩具
public static final int HEALTH = 0x0900;//健康
public static final int UNCATEGORIZED = 0x1F00;//未分类的、未知的
// Devices in the COMPUTER major class
public static final int COMPUTER_UNCATEGORIZED = 0x0100;
public static final int COMPUTER_DESKTOP = 0x0104;
public static final int COMPUTER_SERVER = 0x0108;
public static final int COMPUTER_LAPTOP = 0x010C;
public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110;
public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114;
public static final int COMPUTER_WEARABLE = 0x0118;
// Devices in the PHONE major class
public static final int PHONE_UNCATEGORIZED = 0x0200;
public static final int PHONE_CELLULAR = 0x0204;
public static final int PHONE_CORDLESS = 0x0208;
public static final int PHONE_SMART = 0x020C;
public static final int PHONE_MODEM_OR_GATEWAY = 0x0210;
public static final int PHONE_ISDN = 0x0214;
// Minor classes for the AUDIO_VIDEO major class
public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400;
public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404;
public static final int AUDIO_VIDEO_HANDSFREE = 0x0408;
//public static final int AUDIO_VIDEO_RESERVED = 0x040C;
public static final int AUDIO_VIDEO_MICROPHONE = 0x0410;
public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414;
public static final int AUDIO_VIDEO_HEADPHONES = 0x0418;
public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C;
public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420;
public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424;
public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428;
public static final int AUDIO_VIDEO_VCR = 0x042C;
public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430;
public static final int AUDIO_VIDEO_CAMCORDER = 0x0434;
public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438;
public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C;
public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440;
//public static final int AUDIO_VIDEO_RESERVED = 0x0444;
public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448;
// Devices in the WEARABLE major class //穿戴设备细分
public static final int WEARABLE_UNCATEGORIZED = 0x0700;
public static final int WEARABLE_WRIST_WATCH = 0x0704;
public static final int WEARABLE_PAGER = 0x0708;
public static final int WEARABLE_JACKET = 0x070C;
public static final int WEARABLE_HELMET = 0x0710;
public static final int WEARABLE_GLASSES = 0x0714;
// Devices in the TOY major class 玩具细分
public static final int TOY_UNCATEGORIZED = 0x0800;
public static final int TOY_ROBOT = 0x0804;
public static final int TOY_VEHICLE = 0x0808;
public static final int TOY_DOLL_ACTION_FIGURE = 0x080C;
public static final int TOY_CONTROLLER = 0x0810;
public static final int TOY_GAME = 0x0814;
// Devices in the HEALTH major class 健康设备细分
public static final int HEALTH_UNCATEGORIZED = 0x0900;
public static final int HEALTH_BLOOD_PRESSURE = 0x0904;
public static final int HEALTH_THERMOMETER = 0x0908;
public static final int HEALTH_WEIGHING = 0x090C;
public static final int HEALTH_GLUCOSE = 0x0910;
public static final int HEALTH_PULSE_OXIMETER = 0x0914;
public static final int HEALTH_PULSE_RATE = 0x0918;
public static final int HEALTH_DATA_DISPLAY = 0x091C;
// Devices in PERIPHERAL major class
* @hide
public static final int PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500;
* @hide
public static final int PERIPHERAL_KEYBOARD = 0x0540;
* @hide
public static final int PERIPHERAL_POINTING = 0x0580;
* @hide
public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0;复制代码
使用方式
int deviceType = device.getBluetoothClass().getMajorDeviceClass();
if(deviceType == BluetoothClass.Device.Major.PHONE){
复制代码
* Set priority of the profile
* <p> The device should already be paired.
* Priority can be one of {@link #PRIORITY_ON} orgetBluetoothManager
* {@link #PRIORITY_OFF},
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
* permission.
* @param device Paired bluetooth device
* @param priority
* @return true if priority is set, false on error
* @hidepublicbooleansetPriority(BluetoothDevice device, int priority) {
复制代码
//只针对蓝牙设备的某个profile
int state = mBluetoothAdapter.getProfileConnectionState(A2DP);
//只要蓝牙设备有一种profile处于连接状态,则返回连接状态的state,该方法是hide方法,需要通过反射获得
int state = mBluetoothAdapter.getConnectionState();复制代码