Share via

Bluetooth issue when navigating in XAML

John Thomas 1 Reputation point
2022-01-23T01:26:03.51+00:00

Hi,
I have a Xamarin mobile app in C# that connects to Bluetooth, using Android.Bluetooth. In that XAML page, all the Bluetooth operation is great/fine tested on the Amazon Android device. If I navigate to another XAML page, the remote bluetooth device seems to stay connected (it is BlueSmirf SPP BT for GRBL). I can verify green light on remote device verses red light for not connected. When I navigate back to original bluetooth XAML page, it tells me it cannot read or write to BT and I must be connected to BT. I placed a check into the code, and when navigating back to original BT page, "socket is not equal to null and socket is not connected" were the result????? (I created an if, elseif, elseif, elsif test grid to find out this result). If I try to reconnect to the device and create a socket, it throws an exception. It's like frozen on connected but can't do anything when navigating to another page. Am I not flushing or disposing something before navigating? Can I connect, stay connected, navigate to another XAML, navigate back, and still have a good socket connection? It is ok if I can't accomplish this. I just don't understand the BT behavior during a page navigation.
thanks for your help,
jt

Developer technologies | .NET | Xamarin

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.