1

I have added 20 messages that are in for loop for a group notification like whats app. It is created successfully but all notification is showing, only 7 child group messages are displaying when extending it. It does not show 20 messages when extending` it. But the notification should be displayed all child group messages. I have attached two screenshots for your reference. I have attached the source code too. Please help me, anyone. I am sorry for my English.Thanks in advance

enter image description here

... try { val abs = Math.abs(10)

        var i = Intent(this, MainActivity::class.java)
        i.putExtra("com.schnell.forground.ID", abs)
        val contentIntent = PendingIntent.getActivity(
            this,
            100, i, 0
        )
        var bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_lock_idle_lock)
            val notificationManager =
                getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

            val channelId =
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) createNotificationChannel(
                    notificationManager
                ) else ""
        val SUMMARY_ID = 102
        val GROUP_KEY_WORK_EMAIL = "com.android.example.WORK_EMAIL"
        var j= 10

        val summaryNotification = NotificationCompat.Builder(this, channelId)
            //set content text to support devices running API level < 24
            .setSmallIcon(R.drawable.ic_lock_idle_lock)
            //build summary info into InboxStyle template
            .setStyle(NotificationCompat.InboxStyle()
                .addLine("Alex Faarborg Check this out")
                .addLine("Jeff Chang Launch Party")
                .setBigContentTitle("2 new messages")
                .setSummaryText("4 messages"))
            //specify which group this notification belongs to
            .setGroup(GROUP_KEY_WORK_EMAIL)
            //set this notification as the summary for the group
            .setGroupSummary(true)
            .setAutoCancel(true)
            .setContentIntent(contentIntent)
            .build()

       // val notificationManager1 = NotificationManagerCompat.from(this)
        val newMessageNotification2 = NotificationCompat.Builder(this, channelId)

        for(x in 0 until 20) {
            Log.v("kkkk","---"+j)

            newMessageNotification2.setSmallIcon(R.drawable.alert_light_frame)
            newMessageNotification2.setContentTitle("Title "+x)

            newMessageNotification2.setGroup(GROUP_KEY_WORK_EMAIL)
            newMessageNotification2.setNumber(x)
            newMessageNotification2.setAutoCancel(true)
            newMessageNotification2.build()

            val inboxStyle = NotificationCompat.InboxStyle()

           // newMessageNotification2.setContentText("123456")
            inboxStyle.addLine("fdskfhdsjf")
           // inboxStyle.addLine("123456")
            inboxStyle.setSummaryText("2 messages")
            newMessageNotification2.setStyle(inboxStyle)

            // notificationManager.notify(emailNotificationId1, newMessageNotification1.build())
            notificationManager.notify(emailNotificationId2++, newMessageNotification2.build())
        }
        notificationManager.notify(SUMMARY_ID, summaryNotification)
    } catch (e: Exception) {
        e.printStackTrace()
    }...
user651475
  • 51
  • 1
  • 4
  • That's by [design](https://developer.android.com/training/notify-user/group#set_a_group_summary) "On Android 7.0 (API level 24) and higher, the system automatically builds a summary for your group using snippets of text from each notification." – lasec0203 Mar 15 '21 at 22:01

0 Answers0