仅示出了第一消息通知警报 [英] Notification alert is shown only for the first message

查看:182
本文介绍了仅示出了第一消息通知警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于显示通知的方法如下:

I have the following method for showing notifications:

private void sendNotification(String msg) {
        mNotificationManager = (NotificationManager)
                _context.getSystemService(Context.NOTIFICATION_SERVICE);

        Notification notification = new Notification(R.drawable.menu_cartable,
                "you have a new message",
                System.currentTimeMillis());
        notification.flags = Notification.FLAG_AUTO_CANCEL;
        notification.sound = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        Intent notificationIntent = new Intent(_context, ActCartable.class);
        PendingIntent intent = PendingIntent.getActivity(_context, 0,
                    notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

        notification.setLatestEventInfo(_context,
                "you have a new message",
                msg,
                intent);

        mNotificationManager.notify(NOTIFICATION_ID, notification);

    }


在Android 4.2当收到一个消息的第一次(通知栏被清除),一个大图标(tickerText)显示在通知栏中,几秒钟后,它是隐藏的通知去通知栏。如果我没有打开通知(通知栏不被清除),并接收到第二所通知的,在大图标不被再次显示,但设备正确使声音和新的消息的内容进行更新成功地通知栏,如果用户打开通知栏。

In Android 4.2 When a message is received for the first time (notification bar is cleared), a big icon (tickerText) is shown in notification bar and a few seconds later it is hidden and notification goes to notification bar. If I do not open that notification (notification bar is not cleared) and the second messaged is received, the big icon is not shown again but device makes the sound correctly and the content of the new message is updated successfully in notification bar if the user open the notification bar.

您应该知道,在大图标显示在安卓3.X所有的时间。

You should know that the big icon is shown all time in android 3.x.

我怎么能证明每次收到新的消息,并没有被清除的通知栏?时间的Andr​​oid 4.x的大图标

How can I show that big icon in android 4.x each time a new message is received and notification bar is not cleared?

推荐答案

例如,您可以取消老的通知,并显示一个新的与另一个ID。它看起来是这样的:

For example, you can cancel old notification and display a new one with another id. It will look like this:

mNotificationManager.cancel(notificationId);
mNotificationManager.notify(notificationId++, notification);

按@breceivemail更新:

它正常工作,如果你把 ++ notificationId 是这样的:

It works correctly if you put ++ before notificationId like this:

 mNotificationManager.cancel(notificationId);
 mNotificationManager.notify(++notificationId, notification);

谢谢,

这篇关于仅示出了第一消息通知警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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