Vin*_*ith 5 android android-asynctask
我有一个AsyncTask,它使用轮询队列来查看是否有新对象到达.当它检测到新对象时,我将它作为字符串收集信息,然后发布进度(信息).在onProgressUpdate中,它将字符串添加到列表中.我遇到的问题是程序永远不会进入onProgressUpdate.我在调试器中逐步完成它,我看到它调用了publishProgress,但它从未进入onProgress更新.看起来像这样:
@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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6107 次 |
| 最近记录: |