@@ -307,21 +307,24 @@ private void startForegroundService() {
307
307
assert manager != null ;
308
308
manager .createNotificationChannel (chan );
309
309
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
-
318
310
NotificationCompat .Builder notificationBuilder = new NotificationCompat .Builder (this , NOTIFICATION_CHANNEL_ID );
319
311
notificationBuilder .setOngoing (true )
320
312
.setContentTitle (foregroundSettings .getString ("notificationTitle" ))
321
- .setContentIntent (pendingIntent )
322
313
.setPriority (NotificationManager .IMPORTANCE_MIN )
323
314
.setCategory (Notification .CATEGORY_SERVICE );
324
315
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
+
325
328
if (foregroundSettings .hasKey ("notificationIcon" )) {
326
329
Context context = this .getApplicationContext ();
327
330
Resources res = context .getResources ();
0 commit comments