Did something change with Bluetooth Serial in Android 10?

守給你的承諾、 提交于 2021-02-11 16:27:24

问题


I have a Google Pixel 3a XL on Android 10 that is unable to make a good Bluetooth serial connection to a Bluetooth SPP module using Bluetooth 2.0. However, I can connect to a module with Bluetooth 1.2. I haven't been able to determine if this is related to all of Android 10, or something specific to the Pixel 3 line.

I'm trying to get GPS position data from a GPS receiver via Bluetooth. When I try to bring up a connection using createInsecureRfcommSocketToServiceRecord(), the serial connection actually comes up for 1-5 seconds. I do get some data from the GPS receiver, however there are chunks missing. Then the data stops flowing. In addition to my app, I have tested this with several other Bluetooth serial terminal programs, and they all have the same results - I get some data, then it stops.

I can use this same Bluetooth module with a different Android device running Android 9 and it works great. I can also connect to this Bluetooth module from Windows and it too works fine.

I have a second Bluetooth module that is older (runs Bluetooth v1.2) and surprisingly it actually works fine with the Pixel.

Has anyone else seen issues with Serial over Bluetooth on Android 10?


回答1:


Something that changed with Android 10 is that you need to have your location enabled besides the permission in order to connect to some BLE devices. I'm not sure if this will help you, but can give you some light regarding the issue you're having.

"Some telephony, Bluetooth, Wi-Fi APIs require FINE location permission If your app targets Android 10 or higher, it must have the ACCESS_FINE_LOCATION permission in order to use several methods within the Wi-Fi, Wi-Fi Aware, or Bluetooth APIs. The following sections list the affected classes and methods."

https://developer.android.com/about/versions/10/privacy/changes



来源:https://stackoverflow.com/questions/62198592/did-something-change-with-bluetooth-serial-in-android-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!