In my app am trying to navigate the user back to previous screen where he or when made the app background with Intent flags when clicked on push notification ,but that is not working as expected everytime i try it takes or start from launcher screen itself instead i need to take user to previous activity , if anyone has the solution for it please let me know and i don't need to navigate the user to specific activity
I have tried with Intent flags which i will pasing in notification of setContentIntent()
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
)
}
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())
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744665679a4586734.html
评论列表(0条)