В моем приложении я пытаюсь перейти к пользователю обратно на предыдущий экран, где он или когда сделал фон приложения с флагами намерения, когда нажимает на уведомление о push, но это не работает, как и ожидалось, каждый раз, когда я пробую это, или начинать с самого экрана пускового средства, вместо этого мне нужно привлечь пользователя к предыдущему действия, если у кого -то есть решение, пожалуйста, дайте мне знать, и мне не нужно переносить на интенсивную деятельность. Уведомление SetContentIntent () < /p>
private fun createContentIntent(): PendingIntent {
// Get the application context
val context = applicationContext
// Create an intent with the package name but no specific component
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)?.apply {
// These are the key flags to restore previous state
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
Intent.FLAG_ACTIVITY_CLEAR_TOP or
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
// No other flags needed - Android will handle the rest
}
return PendingIntent.getActivity(
context,
0, // Use a consistent request code for all notifications
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
}
< /code>
val notificationBuilder = NotificationCompat.Builder(this@FirebaseNotificationService, channelId)
.setSmallIcon(R.drawable.kubu_logo_white)
.setContentTitle(title)
.setContentText(message)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.setDefaults(NotificationCompat.GROUP_ALERT_ALL)
.setContentIntent(createContentIntent())
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setTimeoutAfter(10000)
// .setFullScreenIntent(createContent, true) // Add full screen intent
// Show the notification with a unique ID
notificationManager.notify(System.currentTimeMillis().toInt(), notificationBuilder.build())
Подробнее здесь: https://stackoverflow.com/questions/795 ... ground-and