java - 黑莓通知消息问题

标签 java eclipse blackberry notifications message

我试图在单击菜单项时显示通知消息,它​​向我显示了指示器,但我没有看到该消息,有人可以解释我哪里做错了吗:

   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);;
        }
    };

最佳答案

查看您的代码时我注意到两件事:

首先,每次调用菜单项时都会创建一个新的 ReadableListImpl。这意味着您添加消息的 ReadableListImpl 实例并不总是与注册文件夹时使用的实例相同。因此,您的代码应该在第一次调用时有效,但在后续调用中无效。

其次,在 BB OS 6 中,消息可以出现在两个位置:主屏幕(通知栏)和消息列表(“消息”应用程序)。您的消息可能确实显示在消息列表中,但没有显示在通知栏中。根据我的经验,仅当消息的状态为 ApplicationMessage.Status.UNOPENED 时,消息才会显示在通知栏中。

如果您想控制消息的显示位置,请使用 ApplicationFolderIntegrationConfig。

关于java - 黑莓通知消息问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5596507/

相关文章:

Java 服务器无法使用 Blackberry 的 AESkey 加密/解密数据

java - 如何去掉小于一的 double 中小数点前的前导零?

java - MVC设计问题

java - 应用服务器——用还是不用?

通过 J2ME 或 BlackBerry API 进行序列化

blackberry - 未找到 net_rim_json_org

java - 使用依赖项和测试在 Maven 中生成 jar 文件

java - 简单的 java 程序在 Eclipse 中没有输出

eclipse - EGit:如何创建新标签?

java - 包中包含 .java 文件的 Eclipse JNI