I have a problem about activity created twice.
When the notification appears, the activity will appear because of the fullscreen intent. At this time, I press the home button and click the notification, and the activity is actually created again.
I tried to use singletop and it didn't work. Log shows the same task, but the hash is different.
Log.e("Task", "task id: $taskId, hash: ${hashCode()}")
val pendingIntent = PendingIntent.getActivity(context, 0, Intent(context, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
}, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
val builder = NotificationCompat.Builder(context, "Alarm")
.setSmallIcon(R.drawable.ic_launcher_background)
.setContentTitle("Title")
.setContentText("Content")
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setFullScreenIntent(pendingIntent, true)