当我点击菜单项时,我正在尝试发出通知消息,它显示指示器但我没有看到消息,有人可以解释我做错了吗?
private MenuItem AMenu = new MenuItem("Notify", 101, 10)
{
public void run()
{
ReadableListImpl mylist= new ReadableListImpl();
ApplicationMessageFolder folder = null;
if(ApplicationMessageFolderRegistry.getInstance().getApplicationFolder(0x33c7ce29883abe5fL)==null){
folder = ApplicationMessageFolderRegistry.getInstance().registerFolder(
0x33c7ce29883abe5fL, "Test Folder", mylist );
}else {
folder = ApplicationMessageFolderRegistry.getInstance().getApplicationFolder(0x33c7ce29883abe5fL);
}
//DemoMessage source is available in the messagelistdemo.
DemoMessage msg = new DemoMessage("me@here.com", "Pizza Toppings","What would you like on your pizza?", System.currentTimeMillis());
mylist.addMessage(msg);
folder.fireElementAdded(msg,true);
System.out.println("nr of messages"+folder.hasNewMessages());
ApplicationIndicatorRegistry reg =
ApplicationIndicatorRegistry.getInstance();
EncodedImage image = EncodedImage.getEncodedImageResource("new.png" );
ApplicationIcon icon = new ApplicationIcon( image );
ApplicationIndicator indicator = reg.register( icon, false, true);
ApplicationIndicator appIndicator = reg.getApplicationIndicator();
appIndicator.setIcon(icon);
appIndicator.setValue(appIndicator.getValue() + 1);
appIndicator.setNotificationState(true);
appIndicator.setVisible(true);;
}
};
答案 0 :(得分:1)
我注意到有两件事在看你的代码:
首先,每次调用菜单项时都会创建一个新的ReadableListImpl。这意味着您添加消息的ReadableListImpl实例并不总是与注册文件夹时使用的实例相同。因此,您的代码应该在第一次调用时工作,而不是在后续调用中工作。
其次,在BB OS 6中,消息可以出现在两个地方,主屏幕(通知栏)和消息列表('消息'应用程序)。您的邮件可能确实显示在邮件列表中,但不会显示在通知栏中。根据我的经验,仅当消息的状态为ApplicationMessage.Status.UNOPENED时,消息才会显示在通知栏中。
如果您想控制邮件的显示位置,请使用ApplicationFolderIntegrationConfig。