/// <summary> /// Converts a Java Set of android.Bluetooth.BluetoothDevice into its C# representation. /// </summary> /// <param name="bluetoothDeviceJavaSet">The Java Set of android.Bluetooth.BluetoothDevice.</param> /// <returns>The converted <see cref="BluetoothDevice[]"/>.</returns> private static BluetoothDevice[] ConvertJavaBluetoothDeviceSet(AndroidJavaObject bluetoothDeviceJavaSet) { try { if (bluetoothDeviceJavaSet.IsNull()) return null; AndroidJavaObject[] deviceJavaArray = bluetoothDeviceJavaSet.Call<AndroidJavaObject[]>("toArray"); BluetoothDevice[] deviceArray = new BluetoothDevice[deviceJavaArray.Length]; for (int i = 0; i < deviceJavaArray.Length; i++) { deviceArray[i] = new BluetoothDevice(deviceJavaArray[i]); } return deviceArray; } catch { Debug.LogError("Exception while converting BluetoothDevice Set"); throw; } }
private bool Equals(BluetoothDevice other) { return Address.ToLower(CultureInfo.InvariantCulture) == other.Address.ToLower(CultureInfo.InvariantCulture); }
/// <summary> /// Returns <see cref="BluetoothDevice"/> of the current device the application runs on. /// </summary> /// <returns><see cref="BluetoothDevice"/> if Bluetooth connectivity is available and enabled, null otherwise or on error.</returns> public static BluetoothDevice GetCurrentDevice() { if (!_isPluginAvailable) return null; BluetoothDevice currentDevice = new BluetoothDevice(_plugin.Call<string>("getCurrentDevice")); return currentDevice; }