dom*_*nik 5 android bluetooth-lowenergy
我正在查看 android 22 的源代码,将我的代码更改为新的 BLE 扫描,并遇到了 ScanRecord 类。当我打开 ScanRecord 的源代码(sources/android-22/android/bluetooth/le/ScanRecord.java)时,我看到有一个函数 parseFromBytes:
/**
* Parse scan record bytes to {@link ScanRecord}.
* <p>
* The format is defined in Bluetooth 4.1 specification, Volume 3, Part C, Section 11 and 18.
* <p>
* All numerical multi-byte entities and values shall use little-endian <strong>byte</strong>
* order.
*
* @param scanRecord The scan record of Bluetooth LE advertisement and/or scan response.
* @hide
*/
public static ScanRecord parseFromBytes(byte[] scanRecord)
Run Code Online (Sandbox Code Playgroud)
但是如果我尝试在我的代码中使用它,它就找不到该函数。此外,如果我在这里检查 API ,则根本没有提到该功能。
我正在使用带有 compileSdkVersion 22、minSdkVersion 18、targetSdkVersion 22 和 buildToolsVersion 22.0.1 的 Android Studio 1.3.1
我错过了什么?为什么我不能使用该功能,尽管它是android源代码的一部分?
感谢您的澄清。
小智 3
ScanRecord 类已在 API 级别 21 中添加。您可以从ScanResult Code获取它的实例:
ScanCallback leScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
ScanRecord record = result.getScanRecord();
}
}
Run Code Online (Sandbox Code Playgroud)
在该对象实例上,公共函数可用。
| 归档时间: |
|
| 查看次数: |
2143 次 |
| 最近记录: |