Android上的群组通知 [英] Group notifications on Android

查看:115
本文介绍了Android上的群组通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图片上显示通知.如果不止一个,我也想展示一个柜台.我没有在官方文档中找到任何信息.现在,我仅通过id更新通知:

I want to show notifications like on picture. If there is more than one, I want to show a counter too. I didn't find info in official doc. Now I just update my notification by id:

((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
                .notify(PUSH_NOTIFICATION_ID, notification);

我该怎么办?

推荐答案

NotificationCompat.Builder mBuilder = new  NotificationCompat.Builder(getApplicationContext());
            mBuilder.setSmallIcon(R.mipmap.ic_launcher);
            mBuilder.setContentTitle(topic);
            mBuilder.setContentText(new String(message.getPayload()));
            mBuilder.setAutoCancel(true);
            mBuilder.mNumber = 1;//get your number of notification from where you have save notification

            NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            mNotifyMgr.notify(notify_id, mBuilder.build());

这篇关于Android上的群组通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆