Use isMultipleAdvertisementSupported
to check whether PeripheralManager
is supported on this device, closes #83 (#85)
* Use `isMultipleAdvertisementSupported` to check whether `PeripheralManager` is supported on this device. * 6.0.2 * 6.0.2 --------- Co-authored-by: yanshouwang <yanshouwang@outlook.com>
This commit is contained in:
@ -111,7 +111,9 @@ class MyPeripheralManager(context: Context, binaryMessenger: BinaryMessenger) :
|
||||
}
|
||||
|
||||
override fun getState(): MyBluetoothLowEnergyStateArgs {
|
||||
val supported = context.packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)
|
||||
// Use isMultipleAdvertisementSupported() to check whether LE Advertising is supported on this device before calling this method.
|
||||
// See https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothAdapter#getbluetoothleadvertiser
|
||||
val supported = context.packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) && adapter.isMultipleAdvertisementSupported
|
||||
return if (supported) {
|
||||
val authorized = permissions.all { permission -> ActivityCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED }
|
||||
return if (authorized) adapter.state.toBluetoothLowEnergyStateArgs()
|
||||
|
Reference in New Issue
Block a user