I created an app using classic bluetooth. Does it work well on android 10, android 13 but not on android 12? The list of bluetooth slaves remains empty. Do you have an answer to the problem?
Thanhk you.
(Canned Response ABG - Bluetooth non-BLE SCAN Permission Blocks)
The easiest solution, for immediate relief
(from @Barry_Meaker) ...
I had the same issue. The problem is your app does not have permission to see nearby devices. The solution is to give your app permission on your phone (no code changes in your app).
on your phone,
- goto settings
- search for your app
- in App Info for your app select Permissions
- change Nearby Devices from Not Allowed to Allowed
- Done
By the way, the very first time you run the app, Android will ask if you want to grant the app this permission. If you say no, or ignore the pop-up, the permission will be set as Denied. Android will not ask again.
A more complex approach, for professional app development:
These blocks can be dragged into your Blocks Editor to request permission(s) for Bluetooth non-BLE scanning and connecting. All three parts are needed.
You also will need to pull in TinyDB into your project.
Thanks to @Anke for the original code.
My changes include
- use of the Screen1 permission blocks to avoid the possibility of a typo
- using a TinyDB tag particular to BT permissions and only for BT permissions.
(Thanks to @Patryk_F for correction to grant order)
Special note for Xiaomi devices:
Try this one:
and post screenshot(s).
Thank you, i'll try these solutions.