-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No scan results - Pixel 6a Android 13 #135
Comments
I'm having the same issue on a Pixel 7 v 13: |
In android 13, after adding below line is working fine for me. <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s"/> |
any update ? found follow code about No scan results in Samsung S22 Ultra Android 13 class ScanResponse {
var localName: String? = null
}
fun parseName(scanResult: ScanResult): String? {
if (Build.VERSION.SDK_INT >= 33) {
// Android 13
scanResult.scanRecord?.let { scanRecord ->
if (scanRecord.deviceName != null) {
return scanRecord.deviceName
} else {
// If deviceName is null, parse the scan response packet for better compatibility
scanRecord.bytes?.let { rawBytes ->
// rawBytes total length is 62 bytes, the first half is 31 bytes of advertising data,
// and the second half is 31 bytes of scan response data
val scanResponse = parseScanResponse(rawBytes, 31)
return scanResponse.localName
}
}
}
}
return scanResult.scanRecord?.deviceName
}
@TargetApi(33)
fun parseScanResponse(bytes: ByteArray, start: Int): ScanResponse {
val scanResponse = ScanResponse()
var pos = start
var len = bytes[pos].toInt().and(0xff)
var dataType: Int
var data: ByteArray
while (len > 0) {
dataType = bytes[++pos].toInt().and(0xff)
data = bytes.copyOfRange(pos, pos + len - 1)
when (dataType) {
ScanRecord.DATA_TYPE_LOCAL_NAME_SHORT,
ScanRecord.DATA_TYPE_LOCAL_NAME_COMPLETE -> {
val localName = String(data)
println("localName: $localName")
scanResponse.localName = localName
}
// If you need to parse other data, add other DATA_TYPE_xxx as needed
else -> {
println("Data Type: 0x${String.format("%02X", dataType)}, Data: $data")
}
}
pos += len - 1
len = bytes[pos].toInt().and(0xff)
}
return scanResponse
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, during testing devices, I am not getting any results for a Pixel 6a on Android 13.
Working fine on:
Samsung - Galaxy Fold Android 13,
Samsung - (industry phone) Android 12
Pixel 4 - Android 12 and Android 13.
I am aware of many issues at the moment with pixel / android 13 and bluetooth.
Just wondered if anyone else having same issue.
Thanks.
The text was updated successfully, but these errors were encountered: