I have created an app that connects to a Bluetooth BLE module to send commands.
Now the problem is, my app works fine with my HTC phone, but with a Samsung phone it does not show the list to pick the device. Should it be created with special commands for the Samsung phone? I have tested it with two different Samsung phones and both had the same issue! With my HTC the app works without any problem.
I have attached a picture from the list picker part. I do not know if this is enough?
Here I have some pictures from the full Bluetooth connection part. With my HTC M7 it works just fine. With a Samsung S8 or Samsung A40 does not work! I have really no idea why. I plan to buy a new phone as well, because the battery is not good and the kamera is demaged. But if I cannot use my app on the new phone I have to rest with my old HTC.
But with this blocks I have added here I cannot connect with a Samsung phone. Any idea what is wrong with my app? Or is it really a problem with some Samsung phones and I have the luck to get this two models that does have problems with the Bluetooth connection for generally?
When I start my app that I have posted the blocks here, the text “Scanning…” is shown and it appears that it scans correctly. But the list to pick the device does not show on the Samsung, on both Samsungs does not show! With my HTC it works correctly as it should.
A Bluetooth BLE 5.0 device can not be paired like a older Bluetooth version as I know! When I try to pair the module in the Bluetooth settings it does not work on all three phones, the HTC and Samsungs.
Ok. That’s a good start. Were you prompted for location permission when you first called StartScanning? If you check the Settings app on your device and look at the companion’s permissions, does it have Location permission allowed? For Android 6.0 and higher the app needs to request location permission (the version number you have should do that) and the user must grant it before scanning is allowed.
Yes, the window popped up like on the HTC and asked to allowing for location permission. As I have said, it works really everything like on the HTC (where it works!), but it does not pop up the list picker to select the device. As I have set up, the text “Scanning…” appears, so it seems the Samsung scans for Bluetooth devices. As the App comes to the point where I should select the scanned device in the list picker, the Samsung phone does nothing and no list pops up! The text rest on Scanning… and no error message or something else shows. It happens only nothing! When I click a second or third time on the bluetoothButton that I have made it happens nothing else too. That is the actual point I am! I have really no idea why it does not work on the Samsung. I thought Sumsung phones have perhaps other commands that I should need?! If I can test this app on a Huawei too, I will give it a chance! But do not know when I can get a Huawei for testing. My brother has his old phone somewhere, but do not find it at the moment :-/ if the app will work on the Huawei too, I really ask me, what Samsung makes special!
But if someone has another idea, please let me know!
One possible bug in your program, which may or may not be causing issues, is that you call StopScanning in DeviceFound. The DeviceFound event runs multiple times, once for each device encountered while scanning. Maybe there is something the Samsung is reporting that the BLE extension doesn’t know how to interpret, so the event fires but the list is empty, and then scanning stops? What if you temporarily disable the StopScanning block?
Location permission and location services are two different things. Because BLE beacons can contain information about the location of the device in the real world, Google decided to make it so that you also have to request location permission so that the user is aware (in theory) that they might be giving away location information, even if you never use other location services. The BluetoothLE extension does not use location services, but it does ask for location permissions in accordance with the Android requirements.
The BluetoothLE extension is also open source, so you’re welcome to inspect the sources:
Could you clarify what you mean by this? Looking at the blocks, I see an Open call, which makes me think that bluetooth_List is a ListPicker object. It will suffer the same problem as stopping the scanning because the ListPicker’s list of elements is “frozen” at the point Open is called. ListPicker opens a new activity and it is handed the list of elements at the time it starts. It does not dynamically update while it’s open. Instead of opening it, maybe have your “available devices” button also include the length of the elements property to see if it’s growing (after disabling the Open block). If you start seeing the number go up, then you know it’s gathering device info. If it’s always 0, something else is going wrong.