task.addTaskListener(new MessageTaskListener() {
public void onMessage(Task task, Message message) {
if (progress.isCanceled()) {
task.stop();
}
messages.add(message);
progress.setNote(messages.size() + " message" + TextUtils.plural(messages.size()) + " read");
}