How to verify Bluetooth permissions (race condition)

Dear Ugo,

thank you for the tip, I tried it out. Unfortunately, it dropped the same runtime error, only one seconds later, while the user (simulated by me this time) still tried to understand what his phone wants from him again. You may say I should increase the time to 10 seconds. That may solve the problem when the permissions are not granted, which is a one-time action, or at least it's very infrequent. For a change, after giving the permissions, the user need to wait for 10 seconds every time he/she forgot to enable Bluetooth. Also, maybe 10 seconds are not enough...

I hope there is some solution to better check for permissions.

I was also thinking on enabling Bluetooth only when the user clicks on the "Connect" ListPicker. I almost believed I found a good solution; however the ListPicker only has two methods that can be used here; .TouchDown() or .BeforePicking() as I have to enable BT, then populate the Listpicker with the list of available BT devices nearby. All of this before the listpicker list appears.

The result was an empty list and when I closed it down, the notification from my phone appeared that the application wants to enable Bluetooth. I enabled it and the Listpicker worked at the second time but this is not user friendly again. I still believe this can be the solution because I could separate the permission request and the ActivityStarter action from each others. Do you have some tricks, maybe? :slight_smile:

Here are the related methods:


(BTStatus just writes to the screen next to the button, nothing important there.)

Cheers, Atomgep