File tree Expand file tree Collapse file tree
android/src/main/java/com/oney/WebRTCModule Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,6 +116,11 @@ public WebRTCModule(ReactApplicationContext reactContext) {
116116 getUserMediaImpl = new GetUserMediaImpl (this , reactContext );
117117 foregroundServiceController = new ForegroundServiceController (reactContext );
118118 audioOutputManager = new AudioOutputManager (this , reactContext );
119+ }
120+
121+ @ Override
122+ public void initialize () {
123+ super .initialize ();
119124 audioOutputManager .startObserving ();
120125 }
121126
@@ -137,9 +142,11 @@ private PeerConnection getPeerConnection(int id) {
137142 }
138143
139144 void sendEvent (String eventName , @ Nullable ReadableMap params ) {
140- getReactApplicationContext ()
141- .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
142- .emit (eventName , params );
145+ ReactApplicationContext ctx = getReactApplicationContext ();
146+ if (!ctx .hasActiveReactInstance ()) {
147+ return ;
148+ }
149+ ctx .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class ).emit (eventName , params );
143150 }
144151
145152 private PeerConnection .IceServer createIceServer (String url ) {
You can’t perform that action at this time.
0 commit comments