Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 黑莓手机;您当前没有新的通知”;_Java_Blackberry_Blackberry Jde_Localnotification - Fatal编程技术网

Java 黑莓手机;您当前没有新的通知”;

Java 黑莓手机;您当前没有新的通知”;,java,blackberry,blackberry-jde,localnotification,Java,Blackberry,Blackberry Jde,Localnotification,我正在使用下面的代码(特别是pushMessage方法)向用户显示一些通知: public final class MyApplicationMessageFolder { public static final long MyFolderId = 0x1256789012F10123L; private ApplicationMessageFolder folder_; private ApplicationIndicator indicator_; pri

我正在使用下面的代码(特别是
pushMessage
方法)向用户显示一些通知:

public final class MyApplicationMessageFolder 
{
    public static final long MyFolderId = 0x1256789012F10123L;

    private ApplicationMessageFolder folder_;
    private ApplicationIndicator indicator_;
    private MyReadableListImpl collection_;

    public void pushMessage(String subject, String message)
    {
        try 
        {
            if (collection_ == null)
            {
                collection_ = new MyReadableListImpl();
            }
            if (indicator_ == null)
            {
                registerFolderAndIndicator();
            }

            ApplicationMessage am = new MyApplicationMessage(message, subject);
            collection_.addMessage(am);
            folder_.fireElementAdded(am);

            // Update indicator
            int size = collection_.size();
            indicator_.setValue(size);
            indicator_.setVisible(size > 0);
        } 
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

    private void registerFolderAndIndicator()
    {
        // registration application folder and indicator
        ApplicationMessageFolderRegistry amfr = 
                ApplicationMessageFolderRegistry.getInstance();
        folder_ = amfr.getApplicationFolder(MyFolderId );

        if (folder_ == null)
        {
            folder_ = 
                    amfr.registerFolder(MyFolderId , "My Folder", collection_, true);
            ApplicationIcon icon = 
                    new ApplicationIcon(image_ = EncodedImage.getEncodedImageResource("my_icon.png"), true);
            int status = ApplicationMessage.Status.INCOMING | ApplicationMessage.Status.UNOPENED;

            amfr.registerMessageIcon(0, status, icon);
            folder_.setSearchProperties(new ApplicationMessageSearchProperties(true));
            folder_.addListener(
                    new ApplicationMessageFolderListener() {

                        public void actionPerformed(int action, ApplicationMessage[] messages,
                                ApplicationMessageFolder folder) {
                            if (action == ApplicationMessageFolderListener.MESSAGE_DELETED) {
                                for (int i = 0; i < messages.length; i++)
                                    collection_.removeMessage(messages[i]);

                                indicator_.setValue(collection_.size());
                                indicator_.setVisible(collection_.size() > 0);
                            }
                        }
                    },
                    ApplicationMessageFolderListener.MESSAGE_DELETED | 
                            ApplicationMessageFolderListener.MESSAGE_MARKED_OPENED | 
                            ApplicationMessageFolderListener.MESSAGE_MARKED_UNOPENED, 
                    ApplicationDescriptor.currentApplicationDescriptor());

            ApplicationMenuItem[] menu = new ApplicationMenuItem[] {

                    new ApplicationMenuItem(0) {

                        public String toString() {
                            return "Go to application";
                        }

                        public Object run(Object context) {
                            return null;
                        }
                    }
            };

            amfr.registerMessageMenuItems(0, status, menu, 
                    ApplicationDescriptor.currentApplicationDescriptor());
            amfr.setBulkMarkOperationsSupport(0, status, true, false);

            ApplicationIndicatorRegistry air = ApplicationIndicatorRegistry.getInstance();
            air.register(new ApplicationIcon(EncodedImage
                    .getEncodedImageResource("bar_icon_25.png")),
                    false, false);

            indicator_ = air.getApplicationIndicator();
        }
    }

    class MyApplicationMessage implements ApplicationMessage 
    {
        private String message_;
        private String subject_;
        private long timestamp_;

        public MyApplicationMessage(String message, String subject) {
            message_ = message;
            subject_ = subject;
            timestamp_ = new Date().getTime();
        }

        public String getContact() {
            return "HelloWorld";
        }

        public Object getCookie(int cookieId) {
            return null;
        }

        public Object getPreviewPicture() {
            return image_;
        }

        public String getPreviewText() {
            return message_;
        }

        public int getStatus() {
            return ApplicationMessage.Status.UNOPENED;
        }

        public String getSubject() {
            return subject_;
        }

        public long getTimestamp() {
            return timestamp_;
        }

        public int getType() {
            return 0x01;
        }
    }

    private class MyReadableListImpl implements ReadableList {
        private final Vector messages;


        MyReadableListImpl() {
            messages = new Vector();
        }

        public Object getAt(final int index) {
            return messages.elementAt(index);
        }

        public int getAt(final int index, final int count,
                final Object[] elements, final int destIndex) {
            return 0;
        }

        public int getIndex(final Object element) {
            return messages.indexOf(element);
        }

        public int size() {
            return messages.size();
        }

        void addMessage(final ApplicationMessage message) {
            messages.addElement(message);
        }

        void removeMessage(final ApplicationMessage message) {
            messages.removeElement(message);
        }
    }
}
公共最终类MyApplicationMessageFolder { 公共静态最终长MyFolderId=0x1256789012F10123L; 私有应用程序消息文件夹; 专用应用程序指示器; 私有MyReadableListImpl集合; 公共消息(字符串主题、字符串消息) { 尝试 { if(集合=null) { 集合=新的MyReadableListImpl(); } 如果(指示符=null) { registerFolderAndIndicator(); } ApplicationMessage am=新的MyApplicationMessage(消息,主题); 收集添加消息(am); 添加了文件夹\ FireElement(am); //更新指示器 int size=集合大小(); 指示器设置值(大小); 指示器设置可见(大小>0); } 捕获(例外e) { System.out.println(e.getMessage()); } } 专用无效注册表FolderAndIndicator() { //注册申请文件夹和指示器 ApplicationMessageFolderRegistry amfr= ApplicationMessageFolderRegistry.getInstance(); 文件夹=amfr.getApplicationFolder(MyFolderId); 如果(文件夹=null) { 文件夹= amfr.registerFolder(MyFolderId,“我的文件夹”,集合,true); 应用程序图标= 新的应用程序(image_u=EncodedImage.getencodedimagesource(“my_icon.png”),true); int status=ApplicationMessage.status.INCOMING | ApplicationMessage.status.UNOPENED; amfr.registerMessageIcon(0,状态,图标); 文件夹.setSearchProperties(新的ApplicationMessageSearchProperties(true)); 文件夹.addListener( 新的ApplicationMessageFolderListener(){ public void actionPerformed(int action,ApplicationMessage[]消息, ApplicationMessageFolder(文件夹){ if(action==ApplicationMessageFolderListener.MESSAGE\u已删除){ for(int i=0;i0); } } }, ApplicationMessageFolderListener.MESSAGE_已删除| ApplicationMessageFolderListener.MESSAGE_已标记_已打开| ApplicationMessageFolderListener.MESSAGE_已标记_未打开, ApplicationDescriptor.currentApplicationDescriptor()); ApplicationMenuItem[]菜单=新建ApplicationMenuItem[]{ 新的ApplicationMenuItem(0){ 公共字符串toString(){ 返回“转到应用程序”; } 公共对象运行(对象上下文){ 返回null; } } }; amfr.registerMessageMenuItems(0、状态、菜单、, ApplicationDescriptor.currentApplicationDescriptor()); amfr.setBulkMarkOperationsSupport(0,状态,true,false); ApplicationIndicatorRegistry air=ApplicationIndicatorRegistry.getInstance(); 空气调节器(新应用程序)(编码图像 .getEncodeDimagerSource(“bar_icon_25.png”), 假,假),; 指示器=air.getApplicationIndicator(); } } 类MyApplicationMessage实现ApplicationMessage { 私有字符串消息; 私有字符串主语; 私有长时间戳; 公共MyApplicationMessage(字符串消息、字符串主题){ 信息=信息; 主语=主语; 时间戳=新日期().getTime(); } 公共字符串getContact(){ 返回“HelloWorld”; } 公共对象getCookie(int-cookieId){ 返回null; } 公共对象getPreviewPicture(){ 返回图像; } 公共字符串getPreviewText(){ 返回消息; } public int getStatus(){ 返回ApplicationMessage.Status.UNOPENED; } 公共字符串getSubject(){ 返回主题; } 公共长getTimestamp(){ 返回时间戳; } 公共int getType(){ 返回0x01; } } 私有类MyReadableListImpl实现ReadableList{ 私有最终向量消息; MyReadableListImpl(){ 消息=新向量(); } 公共对象getAt(最终整数索引){ 返回消息.elementAt(索引); } 公共整数getAt(最终整数索引、最终整数计数、, 最终对象[]元素,最终int destinex){ 返回0; } public int getIndex(最终对象元素){ 返回消息。indexOf(元素); } 公共整数大小(){ 返回消息。size(); } void addMessage(最终应用程序消息){ 消息。添加元素(消息); } void removeMessage(最终应用程序消息){ messages.removelement(消息); } } } 我可以在我的邮件文件夹中看到我的邮件,但我仍然无法在通知栏中看到它们

有人能解释我为什么这么做吗
ApplicationFolderIntegrationConfig config = new 
        ApplicationFolderIntegrationConfig(true, true, 
        ApplicationDescriptor.currentApplicationDescriptor());
folder_ = amfr.registerFolder(MyFolderId , "My Folder", collection_, config);
folder_ = amfr.registerFolder(MyFolderId , "My Folder", collection_, true);