How to update Notification

走远了吗. 提交于 2019-12-08 04:48:27

问题


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

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?

should I do this:

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

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

or

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

回答1:


The same.

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

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 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.



来源:https://stackoverflow.com/questions/8087310/how-to-update-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!