feat(android): fix case where actions have no data

This commit is contained in:
Calin-Teodor
2025-03-13 14:30:02 +02:00
committed by Calinteodor
parent e9236fd9ff
commit bc65d21ce4

View File

@@ -32,7 +32,13 @@ public class BroadcastReceiver extends android.content.BroadcastReceiver {
BroadcastAction action = new BroadcastAction(intent);
String actionName = action.getType().getAction();
Bundle data = action.getData();
ReactInstanceManagerHolder.emitEvent(actionName, Arguments.fromBundle(data));
// For actions without data bundle (like hangup), we create an empty map
// instead of attempting to convert a null bundle to avoid crashes.
if (data != null) {
ReactInstanceManagerHolder.emitEvent(actionName, Arguments.fromBundle(data));
} else {
ReactInstanceManagerHolder.emitEvent(actionName, Arguments.createMap());
}
}
}