[轉]BluetoothDevice.getType()-一個常常被忽略了的函數。好用的不要不要的


自動安卓發布了4.0版本的藍牙協議之后,越來越多的開發者收到了各種針對於BLE藍牙的開發需求。

而且有很多時候還需要兼容以前的3.0版本,給大家的開發帶來了困擾,筆者也遇到了這樣的問題,偶然間發現了getType()這個函數的妙用。

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)

跟據這個接口,你可以方便的定義一個函數用來分辨搜索到的藍牙設備的版本。如

 

 僅供大家參考使用。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM