Hi, very rare question i would say, I literally made a new project with different name and with the same code with my desired design preferences and when I tried to run the app it failed at the first step(showing bt devices), why???? And also, I noticed that sometimes after I click the switch, state randomly changes from 1 to 0 and vice versa
Your new app does not yet have Bluetooth permissions.
Yeah but it asked for permission after I downloaded it
Stumped here.
Maybe your new device Android Verizon and current AI2 code would help.
It is the same device and the same code I posted above... I really do not understand it
Bluetooth needs at least two permissions
- Scan
- Something else I forget at the moment.
It asks for permission to search for the near devices, to connect to them and establihs their approximate position
(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:
See Bluetooth liste of devices deosn't work anymore - #7 by Anke
Special note for Xiaomi devices:
I have an error with bluetooth on android 12, Xiaomi Poco X3 NFC - #20 by Patryk_F
Well, bad news is that permission to nearby devices was granted from the very beginning😕
Ask for all necessary permissions correctly
Taifun
Can you elaborate on that?
What about following the link to find the recommended blocks?
Taifun
With all due respect but I am having trouble grasping the idea since literally few weeks ago everything worked fine with these blocks...
This thread already is marked as solved... I'm wondering, what we still are discussing here
Taifun
Well I thought it is better to continue here since all of this is based on my project rather than making a new thread starting all over again...
Dear @Bruno_Dragas,
sadly I've not read e-mails for a while, so I read only now.
I believe that what have said @Taifun and @ABG is the best that you can do.
In detail: my Android systems are still "old ones" (i.e.<11) therefore I have no connection restrictions, neither I can test a "new" software that could face such problem.
What I can add are probably only trivial questions (but maybe they can help you in lighting up an idea):
- is this issue rising on the same device where it worked before ?
1.1) if yes, the old one is still working ? - Is it just a new app, with a new name but the with "exactly" the same code as before ?
- Can you try to make again a copy of the old and functioning one (just a pure copy but with a different name so to not overwrite the original one), create the apk and when installing it allow all the permissions required ? This is because, sometimes, if you don't allow a permission at the first installation, the question is not asked again and the permission is not granted for the whole life of the app (at least this is what I've seen sometimes in the past...).
- unistall completely the new app, re-create it and try to re-install it, by allowing all trhe permissions, both at Android level and at installation level.
- cross your fingers and ask some saints....(nope, this one is only a joke )
.....(to be continued, I guess)...
Necessary but not sufficient
Hi, 1; yes and yes
2. yes
what do you mean by the 4th. step/question, after I "copy paste the old app and change the name, grant permissions... ?
I will do that and give my feedback. About the part where I sometimes receive random 0-1 change when I click microswitch(if you remember my project). Do you know the potential reason?
OK let's say it different.
Try to do the 4th, before the 3th: uninstall completely the new one that is not working. and reinstall it by granting "yes" to all the questions that Android will ask at the first installation.
if this does not work, remake a brand new app (with the same contents of the old one, but changing its name) and install it
Please pay attention to what @abg has said, too: you have to grant geolocation also.
The random change could be a "bouncing" of the switch. Or a poor pullup resistor value.
A debouncing example can be found here:
https://docs.arduino.cc/built-in-examples/digital/Debounce/