Android Question Bluetooth device scanning and Android X issue

JagiChan

Member
I have developed an app based on Erel's tutorial using bluetooth. The nearby bluetooth devices scan (i.e., discover function) worked fine on my galaxy S4 (LP 5.0.1).
When I put the app on my shiny new Galaxy S10 with Android X and One UI 2.0, the scan function refuses to work. The log shows nothing and the discovery process keeps on going forever.
Can someone point me in the right direction to get it working. By the way, I changed the Min SDK to 21 and Target SDK to 28 in the mainfest file. Thanks in advance.
 

JagiChan

Member
Tried enabling Location on the device. No joy.
Added the COARSE and FINE LOCATION permissions to the manifest. Still no joy.
Tried degrading the SDK value to 26 (like in your tutorial). Still no joy.

The good news is that if the device is already paired using the Bluetooth connectivity on the phone, then the paired devices shows it up and connects without an issue.
Maybe Android X is special.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

JagiChan

Member
The term Android X is wrong. You are talking about Android 10. AndroidX is the new SDK that replaced Android Support Library.
You are correct. I am refering to Android 10.

This example: https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768/ works on Android 10. You should see a runtime permission request when you run it for the first time.
No joy. I have Runtimepermissions library enabled and I get asked for location permission. Location turns on, but scanning gives no results. The Log is empty.
Running the same program on Galaxy S4 with LP 5.0.1 or Sony Xperia with Marshmellow finds about 10 nearby devices.

Do not bother about it. As of today we have only 2% of devices running Android 10. I'll update the manual to include the workaround (like pair the device from the phone Bluetooth and then connect).
 
Last edited:
Upvote 0
Top