android-bluetooth-serial icon indicating copy to clipboard operation
android-bluetooth-serial copied to clipboard

BluetoothManager.getInstance() never null

Open gbkwiatt opened this issue 5 years ago • 1 comments

It;s probably because I am new to Android / Kotlin.

Trying to make a use of that module, So far working fine with list and bluetooth enabled. I have part of code that checks the instance as in readme:

private var bluetoothManager: BluetoothManager? =BluetoothManager.getInstance()
  override fun onCreate(savedInstanceState: Bundle?) {
    if (bluetoothManager == null) {}
}

But Android studio gives me a hint, that bluetoothManager is never null

gbkwiatt avatar Sep 05 '20 12:09 gbkwiatt

That's strange, in the Kotlin rewrite it looks like this:

https://github.com/harry1453/android-bluetooth-serial/blob/a2075b9444dae1ed6b934d23da78262d48bfb994/androidBluetoothSerial/src/main/java/com/harrysoft/androidbluetoothserial/BluetoothManager.kt#L78

And is quite clearly nullable.

harryjph avatar Oct 05 '20 09:10 harryjph