有谁知道如何在 Honeycomb 中的状态栏通知上施加计数器
我正在尝试使用通知类的数字字段来获取与每个通知关联的“事件数”。对于前。如果我有两封未读电子邮件,状态栏中的电子邮件图标应显示在电子邮件图标上强加的“2”。我认为这对于 froyo 来说工作得很好,但不知怎的,我无法让它为 Honeycomb 工作。这就是我的代码的样子
PendingIntent contentIntent;
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
Notification.Builder builder = new Notification.Builder(this);
builder.getNotification().number = 2;
builder.setSmallIcon(R.drawable.phone_missedcall);
builder.setTicker("ABCD & Status : Missed Call");
notificationIntent = new Intent (this, NotificationSBActivity.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
builder.setContentIntent(contentIntent);
contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
contentView.setImageViewResource(R.id.contact_image, R.drawable.ic_contact_picture);
contentView.setTextViewText(R.id.line_name, "Line 2: Cisco");
builder.setContent(contentView);
,但它没有显示在图标上强加的“2”。还有其他方法可以获取 Honeycomb 中的计数器吗? 另外,尝试过
int icon = R.drawable.phone_app; // icon from resources
CharSequence tickerText = "Hello"; // ticker-text
long when = System.currentTimeMillis(); // notification time
Context context = getApplicationContext(); // application Context
CharSequence contentTitle = "My notification"; // message title
CharSequence contentText = "Hello World!"; // message text
notificationIntent = new Intent(this, NotificationSBActivity.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
// the next two lines initialize the Notification, using the configurations above
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.number = 2;
mNotificationManager.notify(0, notification);
请告诉我是否有人尝试过 Honeycomb 上的通知计数器?
I am trying to use number field of Notification class to get "number of events" associated with each notification. For Ex. If I have two unread emails, email icon in the status bar should show "2" imposed on the email icon. I think this was working fine with froyo but somehow I am not able to make it work for Honeycomb. This is how my code looks like
PendingIntent contentIntent;
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
Notification.Builder builder = new Notification.Builder(this);
builder.getNotification().number = 2;
builder.setSmallIcon(R.drawable.phone_missedcall);
builder.setTicker("ABCD & Status : Missed Call");
notificationIntent = new Intent (this, NotificationSBActivity.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
builder.setContentIntent(contentIntent);
contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
contentView.setImageViewResource(R.id.contact_image, R.drawable.ic_contact_picture);
contentView.setTextViewText(R.id.line_name, "Line 2: Cisco");
builder.setContent(contentView);
But it doesn't show "2" imposed over the icon. Is there any other way to get the counter in Honeycomb ??
Also, tried
int icon = R.drawable.phone_app; // icon from resources
CharSequence tickerText = "Hello"; // ticker-text
long when = System.currentTimeMillis(); // notification time
Context context = getApplicationContext(); // application Context
CharSequence contentTitle = "My notification"; // message title
CharSequence contentText = "Hello World!"; // message text
notificationIntent = new Intent(this, NotificationSBActivity.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
// the next two lines initialize the Notification, using the configurations above
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.number = 2;
mNotificationManager.notify(0, notification);
Please let me know if anyone has tried notification counters on Honeycomb ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论