Summary
When targeting API level 21, a call to startBluetoothSco() (from the android.media.AudioManager package) will throw a NullPointerException unless a bluetooth device is connected to the Android device.
Resolution
There is currently no solution for this issue. But the recommended workaround is to catch the NullPointerException and manage the failed connection appropriately (notify the user, etc).
Sample Code
try { audioManager.startBluetoothSco(); }catch (NullPointerException e){ Log.e(“Exceptions","Null Pointer Exception: No bluetooth receiver Connected”); }
Keywords: Bluetooth, NullPointerException, Wireless, Audio
KB_0015