Android通知栏数量

发布于 2024-09-05 16:02:21 字数 89 浏览 3 评论 0原文

我已经能够在 Android 模拟器上成功显示通知数量。但是,当我在实际的 Android 手机上使用它时,它不会显示任何内容。关于为什么可能存在差异有什么建议吗?

I've been able to successfully display the notification number count on the Android emulator. However, it doesn't display anything when I use it on an actual Android phone. Any suggestions on why there might be a difference?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深海不蓝 2024-09-12 16:02:21

尝试先将其设置为数字 1,然后再设置更高。来自此处的建议: http://developer.android.com/guide/主题/ui/notifiers/notifications.html

数字字段

该值指示通知所代表的当前事件数。适当的数字覆盖在状态栏图标的顶部。如果您打算使用此字段,则首次创建通知时必须以“1”开头。 (如果您在更新期间将该值从零更改为任何更大值,则不会显示该数字。)

Try first setting it up with the number 1, then go higher. Suggestion from here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html

number field

This value indicates the current number of events represented by the notification. The appropriate number is overlaid on top of the status bar icon. If you intend to use this field, then you must start with "1" when the Notification is first created. (If you change the value from zero to anything greater during an update, the number is not shown.)

暮年 2024-09-12 16:02:21

就我而言,这是手机的问题。这是一个不可思议的机器人。它不适用于 android 2.1,但 Verizon 发布的 2.2 解决了这个问题。

In my case it was something with the phone. It was a Droid Incredible. It didn't work with android 2.1, but Verizon's release of 2.2 fixed the issue.

芯好空 2024-09-12 16:02:21

(为了后人)

为了详细说明Izkata所说的,如果您发布了一个没有“数字”计数的通知,并且您想然后添加该数字,您需要取消现有的通知并使用设置的数字字段重新制作它。 (“取消”是NotificationManager 方法之一。)从0 到数字将不会显示该数字,除非您取消原始通知。

同样,如果您有一个带有号码的通知,并且想要返回到空白通知,则需要取消当前通知并重新制作没有号码的通知。从数字到 0 只会显示绿色的小气泡,里面什么也没有。

请注意,如果您只想更改现有号码,只需使用新号码重新发出通知即可,无需取消前一个号码。

(for posterity)

To elaborate on what Izkata said, if you put up a notification with no "number" count and you want to then add the number, you need to cancel the existing notification and remake it with the number field set. ("cancel" is one of the NotificationManager methods.) Going from 0 to a number will not display the number unless you cancel the original notification.

Similarly, if you have a notification up with a number on it and want to go back to a blank notification, you need to cancel the current one and remake it with no number. Going from a number to 0 will just show the little green bubble with nothing in it.

Note that if you just want to change an existing number, you can just re-issue the notification with the new number -- no need to cancel the previous one.

墨洒年华 2024-09-12 16:02:21
      Take two global variable count, i;
         public void createNotification(View view){



NotificationManager mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.logo,
        "A new notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(this,SampleJsonReadingActivity.class);
PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "This is the title",
        "This is the text", activity);
if(count==1){
    count ++;
}
    else{
         i++;

    }
notification.number +=i;
mNotificationManager.notify(0, notification);

它对

我有用......

      Take two global variable count, i;
         public void createNotification(View view){



NotificationManager mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.logo,
        "A new notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(this,SampleJsonReadingActivity.class);
PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "This is the title",
        "This is the text", activity);
if(count==1){
    count ++;
}
    else{
         i++;

    }
notification.number +=i;
mNotificationManager.notify(0, notification);

}

it works for me....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文