mailcore2 IMAPIdleOperation在使用android mailcore2库5分钟后停止接收邮件。任何人都可以提供示例代码如何处理Imap连接很长一段时间。
这是我的代码
echo "123456789012345,3" | awk -F, '($1 ~ /^[[:digit:]]*$/)'
当控制台上显示消息时,IDlE操作停止。
public class ImapIdleNotification extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
startIdle();
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
Log.v(TAG,"Service killed");
}
public void startIdle() {
final IMAPIdleOperation imapIdleOperation = MessagesSyncManager.singleton().session.idleOperation("INBOX", 1888 );
imapIdleOperation.start(new OperationCallback() {
@Override
public void succeeded() {
Log.v("Mailcore","...................Received new mail.........."+);
}
@Override
public void failed(MailException e) {
e.printStackTrace();
}
});
}
}