2

I am getting a NullPointerException reported in one of my apps. The stacktrace gets me to a point where I check some BLE related features.

The code is the following :

private static boolean areHardwareFeaturesSupported(BluetoothManager bluetoothManager) {
    BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
    return bluetoothAdapter != null
            && bluetoothAdapter.isOffloadedFilteringSupported()
            && bluetoothAdapter.isOffloadedScanBatchingSupported();
}

The exception is raised with the following reason :

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.bluetooth.IBluetooth.isOffloadedFilteringSupported()' on a null object reference

I am puzzled as this expression should not even try to invoke the function if the object is null (because of Java's short circuit).

This crash has only been reported on Samsung Galaxy S4 devices (SGH-I337M), running Lollipop (5.0.1).

Has anyone faced this kind of issue, or is something wrong with my code ?

Simon Guerout
  • 652
  • 6
  • 17

0 Answers0