Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Android Bluetooth permission triggering OnAppearing/OnDisappearing

$
0
0

Hi all,

I've stumbled across something that doesn't feel right, but might be worth mentioning.

I have an app that needs to connect to Bluetooth. For this I need to make sure the Bluetooth is on. To turn it on, I ask for the user's permission using the following code (Android only):

Intent enableBtIntent = new Intent(BluetoothAdapter.ActionRequestEnable);
MainActivity.Instance.StartActivityForResult(enableBtIntent, BluetoothRequestCode);

MainActivity.Instance refers to a property in the MainActivity which contains the MainActivity instance.

This code works fine. I get the prompt to ask the user to allow the app to turn on Bluetooth.

The issue comes when this prompt appears, the OnDisappearing() method is triggered, and when I allow/deny Bluetooth access, the OnAppearing() method is triggered.

Given that the prompt appears a simple dialog, I wouldn't expect the page to be "disappearing" when the dialog is opened, and then "reappearing" when the dialog is closed. Is this expected behaviour? If not, am I doing something wrong?

Thanks!


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>