Go Bluetoothdevice.gettype ()-a function that is often ignored. It's good, don't do it.

Source: Internet
Author: User

With the release of the 4.0 Bluetooth protocol, a growing number of developers have received various development requirements for BLE Bluetooth.

And there are many times also need to be compatible with the previous 3.0 version, to the development of people to bring trouble, the author also encountered such problems, accidentally found GetType () This function of the magical.

public int GetType () Added in API level 18

Get the Bluetooth device type of the remote device.

Returns the device type Device_type_classic, Device_type_le device_type_dual. Device_type_unknown if it ' s not available

public static final int device_type_classic Added in API level 18

Bluetooth device type, CLASSIC–BR/EDR devices Constant value:1 (0x00000001)

public static final int device_type_dual Added in API level 18

Bluetooth device type, Dual mode–br/edr/le Constant value:3 (0x00000003)

public static final int Device_type_le Added in API level 18

Bluetooth device type, low energy–le-only Constant value:2 (0x00000002)

public static final int Device_type_unknown Added in API level 18

Bluetooth device type, Unknown Constant value:0 (0x00000000)

According to this interface, you can easily define a function to distinguish between the search for the Bluetooth device version. Such as

12345678910111213141516 public static String devicetypetystring(int paramint) { Switch (paramint) { default: return "UNKNOWN"; Case 1: return "CLASSIC"; Case 3: return "CLASSIC and BLE"; Case 2: } return "BLE only"; } public static boolean isbledevice ( Span class= "crayon-h" > bluetoothdevice device ) { /span> return (device. GetType() = = 2); }

It is for reference only.
    • This article fixed link: http://4past.net/?p=72
    • Reprint Please specify: Mr. X September 02, 2015 at Mr. X published

Go Bluetoothdevice.gettype ()-a function that is often ignored. It's good, don't do it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.