Beispiel #1
0
 private async void ShowPairErrorOccurred(string step, string details)
 {
     await Device.InvokeOnMainThreadAsync(async() =>
     {
         await CurrentCoreMethods.DisplayAlert("Pair Error Occurred",
                                               "An error occurred during " + step + ", exception: " + details, "OK");
     });
 }
Beispiel #2
0
        private async Task HandleBluetoothException(Exception e)
        {
            await Device.InvokeOnMainThreadAsync(async() =>
            {
                switch (e)
                {
                case PermissionsException _:
                    await CurrentCoreMethods.DisplayAlert("Permissions Denied",
                                                          "The necessary permissions for pairing were not granted. Exception: " + e, "OK");
                    break;

                case BluetoothNotSupportedException _:
                    await CurrentCoreMethods.DisplayAlert("Bluetooth Not Supported",
                                                          "Bluetooth is not supported on this device. Exception: " + e, "OK");
                    break;

                case BluetoothFailedToSearchException _:
                    await CurrentCoreMethods.DisplayAlert("Failed to Search",
                                                          "The device failed to search for devices. Exception: " + e, "OK");
                    break;

                case BluetoothNotTurnedOnException _:
                    await CurrentCoreMethods.DisplayAlert("Bluetooth Not On",
                                                          "The device failed to power on Bluetooth. Exception: " + e, "OK");
                    break;

                case WiFiTurnedOffException _:
                    await CurrentCoreMethods.DisplayAlert("Wi-Fi Off",
                                                          "Wi-Fi is turned off. Please turn Wi-Fi on.", "OK");
                    break;

                case LocationServicesNotEnabledException _:
                    await CurrentCoreMethods.DisplayAlert("Location Services Needed",
                                                          "Location services not activated. Cannot scan for devices. See the pairing page for more details.", "OK");
                    break;

                case LocationPermissionNotGrantedException _:
                    await CurrentCoreMethods.DisplayAlert("Location Permission Needed",
                                                          "Location permission not granted. Cannot scan for devices. See the pairing page for more details.", "OK");
                    break;

                default:
                    await CurrentCoreMethods.DisplayAlert("Error",
                                                          "An error occurred. Exception: " + e, "OK");
                    break;
                }
            });
        }