我有一个AsynkTask:
new AsyncTask<Void,Void,Void>() { private ProgressDialog mProgressDialog; @Override protected void onPreExecute() { Log.i(TAG,"Pre execute: " + System.currentTimeMillis()); super.onPreExecute(); mProgressDialog = ProgressDialog.show(NewWeatherActivity.this,null,getResources().getString(R.string.weather_is_updating)); mProgressDialog.setCancelable(false); Log.i(TAG,"Pre executed: " + System.currentTimeMillis()); } @Override protected Void doInBackground(Void... voids) { Log.i(TAG,"Do in background: " + System.currentTimeMillis()); // Some actions Log.i(TAG,"Done in background: " + System.currentTimeMillis()); return null; } @Override protected void onPostExecute(Void aVoid) { Log.i(TAG,"Post execute: " + System.currentTimeMillis()); super.onPostExecute(aVoid); mProgressDialog.dismiss(); Log.i(TAG,"Post executed: " + System.currentTimeMillis()); } }.execute();
日志:
I/TVLauncher/NewWeatherActivity(21691): Pre execute: 1354798705667
I/TVLauncher/NewWeatherActivity(21691): Pre executed: 1354798705713
I/TVLauncher/NewWeatherActivity(21691): Do in background:
1354798724063 I/TVLauncher/NewWeatherActivity(21691): Done in
background: 1354798724083 I/TVLauncher/NewWeatherActivity(21691): Post
execute: 1354798724083 I/TVLauncher/NewWeatherActivity(21691): Post
executed: 1354798725046
因此,onPreExecute和doInBackground之间的延迟大约是19秒.为什么?
解决方法
原文地址:https://www.jb51.cc/android/309309.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。