我有一个AsyncTask使用轮询队列来查看是否有新对象到达。当它检测到新对象时,我将它作为一个字符串收集信息,然后publishProgress(info)。在onProgressUpdate中,它将字符串添加到列表中。我遇到的问题是程序从不进入进度更新。我在调试器中通过它,我看到它调用publishProgress,但它永远不会进入onProgress更新。看起来像这样:publishProgress not calling onProgressUpdate
@Override
protected void onProgressUpdate(String... values) {
messageQueue.add(displayName + " : " + values[0]); //I have a breakpoint here that the program never hits.
((BaseAdapter) getListAdapter()).notifyDataSetChanged();
super.onProgressUpdate(values);
}
@Override
protected Void doInBackground(Void... params) {
while (true) {
Packet p = pc.pollResult();
if(p != null){
String body = ((Message) p).getBody(); //I have a breakpoint here that the program hits only when a new object is in the queue
publishProgress(body);
}
}
}
奇怪,你有没有尝试将字符串正文改为String数组? – Jack
对不起,这太浪费了一篇文章,我想我的模拟器只是在跳过自己。我重新启动日食,一切正常工作... –
我打算推荐,但认为它可能downvoted :) – Jack