@@ -120,7 +120,7 @@ private void acceptDialing() {
120120 params .putBoolean ("done" , true );
121121 params .putString ("uuid" , uuid );
122122
123- if (IncomingCallModule .reactContext .hasCurrentActivity () && isAppOnForeground ()) {
123+ if (IncomingCallModule .reactContext .hasCurrentActivity () && isAppOnForeground (IncomingCallModule . reactContext )) {
124124 // App in foreground, send event for app to listen
125125 sendEvent ("answerCall" , params );
126126 } else {
@@ -136,7 +136,7 @@ private void acceptDialing() {
136136 b .putString ("uuid" , uuid );
137137 i .putExtras (b );
138138 IncomingCallModule .reactContext .startActivity (i );
139- } catch (Exception e ) {
139+ } catch (Exception e ) {
140140 Log .e ("RNIncomingCall" , "Class not found" , e );
141141 return ;
142142 }
@@ -194,17 +194,17 @@ private void sendEvent(String eventName, WritableMap params) {
194194 .emit (eventName , params );
195195 }
196196
197- private boolean isAppOnForeground () {
197+ private boolean isAppOnForeground (ReactApplicationContext context ) {
198198 /**
199199 * We need to check if app is in foreground otherwise the app will crash.
200200 * http://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not
201201 **/
202- ActivityManager activityManager = (ActivityManager ) IncomingCallModule . reactContext .getSystemService (Context .ACTIVITY_SERVICE );
202+ ActivityManager activityManager = (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
203203 List <ActivityManager .RunningAppProcessInfo > appProcesses = activityManager .getRunningAppProcesses ();
204204 if (appProcesses == null ) {
205205 return false ;
206206 }
207- final String packageName = IncomingCallModule . reactContext .getPackageName ();
207+ final String packageName = context .getPackageName ();
208208 for (ActivityManager .RunningAppProcessInfo appProcess : appProcesses ) {
209209 if (appProcess .importance == ActivityManager .RunningAppProcessInfo .IMPORTANCE_FOREGROUND
210210 && appProcess .processName .equals (packageName )) {
0 commit comments