admin管理员组文章数量:1415481
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())
本文标签:
版权声明:本文标题:android - How can i nvaigate user back to previous screen when app came to background and when user cliks on the push notificati 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744665679a2618516.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论