javamail-Android 如何监听收件箱中的邮件被删除或者添加?

Mr_Gao 发布于 2016/10/13 09:21
阅读 585
收藏 0

目前使用的是 1.55的android-javamail,登陆是IMAP,调用的是Folder的AddMessageCountListener,下面上代码

final IdleManager idleManager = new IdleManager(mSession, mEs);
        Folder folder = mStore.getFolder("INBOX");
        folder.open(Folder.READ_WRITE);
        folder.addMessageCountListener(new MessageCountAdapter() {
            public void messagesAdded(MessageCountEvent ev) {
                Folder folder = (Folder)ev.getSource();
                Message[] msgs = ev.getMessages();
                System.out.println("Folder: " + folder +
                        " got " + msgs.length + " new messages");
                try {
                    // process new messages
                    idleManager.watch(folder); // keep watching for new messages
                } catch (MessagingException mex) {
                    // handle exception related to the Folder
                }
            }
        });
        idleManager.watch(folder);



然后在log中会看到这些log

W/System.err: javax.mail.MessagingException: Folder is not using SocketChannels
 W/System.err:     at com.sun.mail.imap.IdleManager.watch(IdleManager.java:203)
 W/System.err:     at com.ram.testdemo.mail.RMail.listenerFolder(RMail.java:411)
 W/System.err:     at com.ram.testdemo.MailActivity$6.run(MailActivity.java:174)
 W/System.err:     at java.lang.Thread.run(Thread.java:818)

报错的地方是,这一句

idleManager.watch(folder);



请问有什么解决方案?

加载中
0
朱旭超
朱旭超
 properties添加mail.imaps.usesocketchannels属性
返回顶部
顶部