enter image description here
The first notification is the original notification and the second notification is the notification I duplicated.
However, even though it is the same device, you can see that the positions of the two notification icons are different.
I want to duplicate the position of the icon in the original notification to match its location.
The code below is where I copy the original notification.
<code>private fun sendDelayedNotification(sbn: StatusBarNotification) {
val senderName = sbn.notification.extras.getString(Notification.EXTRA_TITLE) ?: "Unknown" // 발신자의 TITLE 추출
val uniqueNotificationId = senderName .hashCode() // TITLE만을 기반으로 고유 ID 생성
val channelID = "delayed_channel_id"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelID, "Delayed Notifications", NotificationManager.IMPORTANCE_DEFAULT)
notificationManager.createNotificationChannel(channel)
val originalNotification = sbn.notification
val extras = originalNotification.extras
val smallIcon = originalNotification.smallIcon
val largeIcon = originalNotification.getLargeIcon()
val smallIconCompat = IconCompat.createFromIcon(this, smallIcon)
val largeIconBitmap = largeIcon?.let { iconToBitmap(it, this) }
val title = originalNotification.extras.getString(Notification.EXTRA_TITLE) ?: "Notification"
val text = originalNotification.extras.getString(Notification.EXTRA_TEXT) ?: "No details available"
val contentIntent = originalNotification.contentIntent
val newNotification = smallIconCompat?.let {
NotificationCompat.Builder(this, channelID)
.setSmallIcon(it) // 아이콘 설정
.setLargeIcon(largeIconBitmap)
.setContentIntent(contentIntent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.addExtras(Bundle().apply { putBoolean("isDelayedNotification", true) })
.setExtras(Bundle(extras)) // 모든 추가 데이터를 복사
notificationManager.notify(uniqueNotificationId, newNotification)
<code>private fun sendDelayedNotification(sbn: StatusBarNotification) {
val senderName = sbn.notification.extras.getString(Notification.EXTRA_TITLE) ?: "Unknown" // 발신자의 TITLE 추출
val uniqueNotificationId = senderName .hashCode() // TITLE만을 기반으로 고유 ID 생성
val channelID = "delayed_channel_id"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelID, "Delayed Notifications", NotificationManager.IMPORTANCE_DEFAULT)
notificationManager.createNotificationChannel(channel)
}
val originalNotification = sbn.notification
val extras = originalNotification.extras
val smallIcon = originalNotification.smallIcon
val largeIcon = originalNotification.getLargeIcon()
val smallIconCompat = IconCompat.createFromIcon(this, smallIcon)
val largeIconBitmap = largeIcon?.let { iconToBitmap(it, this) }
val title = originalNotification.extras.getString(Notification.EXTRA_TITLE) ?: "Notification"
val text = originalNotification.extras.getString(Notification.EXTRA_TEXT) ?: "No details available"
// 알림을 클릭할 때 액션 정의
val contentIntent = originalNotification.contentIntent
// 새로운 알림 생성 및 발송
val newNotification = smallIconCompat?.let {
NotificationCompat.Builder(this, channelID)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(it) // 아이콘 설정
.setLargeIcon(largeIconBitmap)
.setContentIntent(contentIntent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
.addExtras(Bundle().apply { putBoolean("isDelayedNotification", true) })
.setExtras(Bundle(extras)) // 모든 추가 데이터를 복사
.build()
}
notificationManager.notify(uniqueNotificationId, newNotification)
}`
</code>
private fun sendDelayedNotification(sbn: StatusBarNotification) {
val senderName = sbn.notification.extras.getString(Notification.EXTRA_TITLE) ?: "Unknown" // 발신자의 TITLE 추출
val uniqueNotificationId = senderName .hashCode() // TITLE만을 기반으로 고유 ID 생성
val channelID = "delayed_channel_id"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(channelID, "Delayed Notifications", NotificationManager.IMPORTANCE_DEFAULT)
notificationManager.createNotificationChannel(channel)
}
val originalNotification = sbn.notification
val extras = originalNotification.extras
val smallIcon = originalNotification.smallIcon
val largeIcon = originalNotification.getLargeIcon()
val smallIconCompat = IconCompat.createFromIcon(this, smallIcon)
val largeIconBitmap = largeIcon?.let { iconToBitmap(it, this) }
val title = originalNotification.extras.getString(Notification.EXTRA_TITLE) ?: "Notification"
val text = originalNotification.extras.getString(Notification.EXTRA_TEXT) ?: "No details available"
// 알림을 클릭할 때 액션 정의
val contentIntent = originalNotification.contentIntent
// 새로운 알림 생성 및 발송
val newNotification = smallIconCompat?.let {
NotificationCompat.Builder(this, channelID)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(it) // 아이콘 설정
.setLargeIcon(largeIconBitmap)
.setContentIntent(contentIntent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
.addExtras(Bundle().apply { putBoolean("isDelayedNotification", true) })
.setExtras(Bundle(extras)) // 모든 추가 데이터를 복사
.build()
}
notificationManager.notify(uniqueNotificationId, newNotification)
}`