Hello everyone.
I'm trying to make an application that connects to a device via Bluetooth.
I found all kinds of code snippets and did a lot of experiments.
Unfortunately, I was unable to do the following 3 things after installing the .apk application on my phone:
At the first startup, the application must do the following 3 things:
ask for approval to see Nearby devices and if approval is received then validate this option in the phone settings
ask for approval to turn on Bluetooth if it is turned off and if approval is received then validate this option in the phone settings
ask for approval to turn on Location if it is turned off and if approval is received then validate this option from the phone settings
Do you think you can help me?
(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:
Thanks for the suggestions, but I would like not to do this manually, I would like the application to do these things automatically. So how can I do this in code?
It would be desirable for the Bluetooth control itself to do this automatically or to have some properties that could be enabled/disabled according to everyone's wish.