如何更新通知 [英] How to update Notification

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

问题描述

我的Android应用程序中有一个Notification.这个Notification有一个进度条.

I have a Notification in my android application. And this Notification has a progress bar.

我的问题是:如果我在Notification的进度栏中更新进度,我应该传递Notification的SAME实例还是创建Notification的新实例?

My question is: if I update progress in the progress bar of my Notification, should I pass the SAME instance of Notification or create a new instance of Notification?

我应该这样做:

mNotification = new Notification(..); // create in the constructor of my activity

getNotificationManager().notify(TAG, FILE_UPLOAD_ID, mNotification);

getNotificationManager().notify(TAG, FILE_UPLOAD_ID, new Notification(...) );

推荐答案

相同.

public void notify(字符串标签,整数ID,通知通知) 由于:API级别5

public void notify (String tag, int id, Notification notification) Since: API Level 5

发布要在状态栏中显示的通知. 如果有通知 具有相同标签和ID的标签已由您的应用发布 并且尚未取消,它将被更新的 信息. *

Post a notification to be shown in the status bar. If a notification with the same tag and id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information. *

Parameters标签为此的字符串标识符 通知.可能为空. id此通知的标识符. 该对(标签,ID)在您的应用程序中必须是唯一的. Notification一个Notification对象,描述向用户显示什么. 不能为空.

Parameters tag A string identifier for this notification. May be null. id An identifier for this notification. The pair (tag, id) must be unique within your application. notification A Notification object describing what to show the user. Must not be null.

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

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