我有一個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