@@ -307,21 +307,24 @@ private void startForegroundService() {
307307 assert manager != null ;
308308 manager .createNotificationChannel (chan );
309309
310- Activity currentActivity = RNCallKeepModule .instance .getCurrentReactActivity ();
311- Intent notificationIntent = new Intent (this , currentActivity .getClass ());
312- notificationIntent .addFlags (Intent .FLAG_ACTIVITY_SINGLE_TOP );
313-
314- final int flag = Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ? PendingIntent .FLAG_UPDATE_CURRENT | PendingIntent .FLAG_IMMUTABLE : PendingIntent .FLAG_UPDATE_CURRENT ;
315-
316- PendingIntent pendingIntent = PendingIntent .getActivity (this , NOTIFICATION_ID , notificationIntent , flag );
317-
318310 NotificationCompat .Builder notificationBuilder = new NotificationCompat .Builder (this , NOTIFICATION_CHANNEL_ID );
319311 notificationBuilder .setOngoing (true )
320312 .setContentTitle (foregroundSettings .getString ("notificationTitle" ))
321- .setContentIntent (pendingIntent )
322313 .setPriority (NotificationManager .IMPORTANCE_MIN )
323314 .setCategory (Notification .CATEGORY_SERVICE );
324315
316+ Activity currentActivity = RNCallKeepModule .instance .getCurrentReactActivity ();
317+ if (currentActivity != null ) {
318+ Intent notificationIntent = new Intent (this , currentActivity .getClass ());
319+ notificationIntent .addFlags (Intent .FLAG_ACTIVITY_SINGLE_TOP );
320+
321+ final int flag = Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ? PendingIntent .FLAG_UPDATE_CURRENT | PendingIntent .FLAG_IMMUTABLE : PendingIntent .FLAG_UPDATE_CURRENT ;
322+
323+ PendingIntent pendingIntent = PendingIntent .getActivity (this , NOTIFICATION_ID , notificationIntent , flag );
324+
325+ notificationBuilder .setContentIntent (pendingIntent );
326+ }
327+
325328 if (foregroundSettings .hasKey ("notificationIcon" )) {
326329 Context context = this .getApplicationContext ();
327330 Resources res = context .getResources ();
0 commit comments