我曾经AsyncTask请求大量数据。收到后,数据在方法内部进行onPostExecute处理。处理数据可能需要一段时间。
根据我的理解,AsyncTask它是异步的并且独立于 UI。
- 为什么我的活动冻结
onPostExecute? - 如果方法内部的处理时间过长
Activity,冻结是否正常?onPostExecute - 我怎样才能使它
Activity不会冻结onPostExecute?
我曾经AsyncTask请求大量数据。收到后,数据在方法内部进行onPostExecute处理。处理数据可能需要一段时间。
根据我的理解,AsyncTask它是异步的并且独立于 UI。
onPostExecute?Activity,冻结是否正常?onPostExecuteActivity不会冻结onPostExecute?database , network ,parsing在方法中执行所有数据源操作,例如(response.etc)doInBackground。onProgressUpdateonPostExecute。尝试parsed data在postexecute.为什么我的 Activity 在 PostExecute 上冻结?
根据您的帖子,您对 PostExecute 方法执行了一些耗时的操作。在 PostExecute 上运行在 UI 线程上,所以你的 UI 被冻结没关系。
如果 onPostExecute 方法内部的处理时间过长,Activity 冻结是否正常?
是的,它就是。您应该在 doInBackground 方法中执行长操作(非 UI 线程)
如何使我的 Activity 不会在 PostExecute 上冻结?
尝试将您的长时间操作转移到 doInBackground 方法,并在 PostExecute 中根据响应更新 UI,这是您在 doInBackground 方法中的操作后得到的。
确保您在doInBackground方法中使用AsynTask方法。
请参阅 Long Running Task You Need to Bind in doInBackground here you cannot Bind UI control LikeButton等ImageView 。在完成后 doInBackground 您onPostExecute 可以 Bind All Require Control ,请确保此处 [ onPostExecute] 您没有运行其他任务。