- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 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);
}
}
}
最佳答案
我遇到了一个问题,它没有被调用,但我只是注意到我把它放在了错误的类中。它当然应该在 AsyncTask block 内,但实际上我是在该 block 外创建的
关于android - publishProgress 不调用 onProgressUpdate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7194070/
private class DownloadTextTask extends AsyncTask { CharSequence contentText; Context
我正在使用 Retrofit 从 api 接收 json 数据,并且工作完美,但将来我想显示进度条。我决定实现 onProgressUpdate 来检查是否调用了此方法,但在检查 Logcat 选项卡
我正在练习 AsyncTask 的工作,为此我想使用 onProgressUpdate 函数。目前在我的程序中,我有一个 UI,它允许用户选择输入(在 AsyncTask 完成后将显示在 TextVi
我是一名新程序员。我看过很多教程,但不明白哪里出了问题。我正在尝试从异步任务创建 ProgressBar。但是它总是使我的应用程序崩溃。 这是“主”应用程序: package pt.flag.ense
是否有可能某些调用 publishProgress 被 onProgressUpdate 遗漏了?我的意思是,在使用 publishProgress 调用的情况下,doInBackground 和 o
我从过去 2 天开始就一直卡住了。在我的情况下,没有调用 onProgressUpdate() 。所以它没有更新进度条。任何人都可以看看并提出建议吗?谢谢。这是我的代码 package com.exa
我试图通过 onprogress 更新方法只显示一次通知。存在允许显示通知的条件。问题是它在第一个通知之后继续显示通知,并且手机一直在响铃和振动。我只想收到一个关于某事的通知并停止。有可能吗?有人可以
我的 asynctask 没有进入 onProgressUpdate。为什么?我将在 asynctask 中创建进度条。下面是我的代码,使用进度条显示上传图像。 public static class
我在onCreate中有这个GetAllUsers();并且我有这个 private void GetAllUsers() { (new LoadingUsers(this)).execute()
目标: 基于使用异步的 onProgressUpdate 显示文本“Test”。 问题: 我不明白为什么代码不显示文本“测试”。 我错过了什么? 谢谢! 信息: *我是安卓新手 *我正在使用 API
我通过了一些指南,我知道如何像这样将许多参数传递给 onProgressUpdate @Override protected void doInBackground(Void... params){
编辑:我将这个 pB = (ProgressBar) findViewById(R.id.progressBar); 放在 onPreExecute() 中。它有效,一切都有效。但这是一个好的解决方案
我有一个 AsyncTask,它使用轮询队列来查看是否有新对象到达。当它检测到新对象时,我让它以字符串形式收集信息,然后发布进度(信息)。在 onProgressUpdate 中,它将字符串添加到列表
我目前正在使用 Square 的 Retrofit 进行 Android 网络通信。有没有办法在创建进度通知的任务期间获取进度,类似于 Facebook 在上传图片时使用的方法? 用例是在不压缩或缩放
我想显示下载图像的进度条并设置自定义颜色我在 onProgressUpdate() 中执行此操作,但它不起作用,它也不会出现在 logcat 中。它还会显示白屏,直到下载完成,如果我在下载过程中按后退
我有一个异步方法,可以在 Google map View 上放置标记。在下面的代码中,我尝试将对象 overrideitem 传递到 onProgressUpdate 方法中。我收到编译器错误,指出
我正在使用 AsyncTask 计算一个 double 值,然后我想发布这个 double 值 private class CalcTask extends AsyncTask{ @Overr
我在函数 onProgressUpdate 上出现“ArrayIndexOutOfBoundsException”错误我认为一切正常,但找不到问题所在。当这个任务要运行时,logcat 说 Array
在 Asyntask 中,我在 Asyntask 的全局变量中实例化了一个进度对话框: ProgressDialog progressDialog; 然后,在 DoInBackGround 中,我调用
我有以下代码在异步任务中运行客户端套接字连接: @Override protected Boolean doInBackground(Void... params) { //This runs on
我是一名优秀的程序员,十分优秀!