Skip to content

Commit 16c562a

Browse files
authored
AppRTCBluetoothManager.java | Redundantly handle null case when unregistering
i don't have nice experience with this but I did have this on a project and reduced a lot of crashlogs-- I kinda don't understand why `receiver` at this point would be null
1 parent 6268139 commit 16c562a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

android/src/main/java/com/zxcpoiu/incallmanager/AppRTC/AppRTCBluetoothManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,15 @@ protected void registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
468468
}
469469
}
470470
protected void unregisterReceiver(BroadcastReceiver receiver) {
471-
apprtcContext.unregisterReceiver(receiver);
471+
if (receiver != null) {
472+
try {
473+
apprtcContext.unregisterReceiver(receiver);
474+
} catch (final Exception exception) {
475+
// The receiver was not registered.
476+
// There is nothing to do in that case.
477+
// Everything is fine.
478+
}
479+
}
472480
}
473481
protected boolean getBluetoothProfileProxy(
474482
Context context, BluetoothProfile.ServiceListener listener, int profile) {

0 commit comments

Comments
 (0)