|
23 | 23 | import android.app.Notification; |
24 | 24 | import android.app.NotificationChannel; |
25 | 25 | import android.app.NotificationManager; |
| 26 | +import android.app.PendingIntent; |
| 27 | +import android.app.Activity; |
26 | 28 | import android.content.res.Resources; |
27 | 29 | import android.content.Intent; |
28 | 30 | import android.content.Context; |
@@ -82,6 +84,7 @@ public class VoiceConnectionService extends ConnectionService { |
82 | 84 | private static ConnectionRequest currentConnectionRequest; |
83 | 85 | private static PhoneAccountHandle phoneAccountHandle; |
84 | 86 | private static String TAG = "RNCallKeep"; |
| 87 | + private static int NOTIFICATION_ID = -4567; |
85 | 88 |
|
86 | 89 | // Delay events sent to RNCallKeepModule when there is no listener available |
87 | 90 | private static List<Bundle> delayedEvents = new ArrayList<Bundle>(); |
@@ -304,9 +307,18 @@ private void startForegroundService() { |
304 | 307 | assert manager != null; |
305 | 308 | manager.createNotificationChannel(chan); |
306 | 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 | + |
307 | 318 | NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID); |
308 | 319 | notificationBuilder.setOngoing(true) |
309 | 320 | .setContentTitle(foregroundSettings.getString("notificationTitle")) |
| 321 | + .setContentIntent(pendingIntent) |
310 | 322 | .setPriority(NotificationManager.IMPORTANCE_MIN) |
311 | 323 | .setCategory(Notification.CATEGORY_SERVICE); |
312 | 324 |
|
|
0 commit comments