【问题标题】:Skipping frames, not showing progressdialog跳帧,不显示进度对话框
【发布时间】:2015-05-08 23:20:11
【问题描述】:

我在 AsyncTask 中使用了 progressDialog,但它没有显示 progressDialog 并且它也在跳帧。这是日志:

05-09 00:09:41.958: E/pass 1(16031): Connection success 
05-09 00:09:41.968: E/pass 2(16031): Result: Success!
05-09 00:09:41.978: I/System.out(16031): Out background...
05-09 00:09:41.978: I/Choreographer(16031): Skipped 56 frames!  The application may be doing too much work on its main thread.
05-09 00:09:42.008: I/System.out(16031): In onPostExecute...
05-09 00:09:42.018: I/System.out(16031): Committed.
05-09 00:09:42.018: I/System.out(16031): Out onPostExecute...

这里是代码:

protected void onPreExecute() {
    progressDialog = ProgressDialog.show(NewNote.this, "", "");
    progressDialog.setCancelable(false);
    progressDialog.setContentView(R.layout.progressdialog);
    progressDialog.show();
}

protected Void doInBackground(Void... params) {
   System.out.println("In background...");
   //connecting to the internet and saving the shared preference
   System.out.println("Out background...");
        return null;
}

protected void onPostExecute(Void result) {
    System.out.println("In onPostExecute...");
    progressDialog.dismiss();
    System.out.println("Committed.");
    setResult(RESULT_OK, data);
    finish();
    System.out.println("Out onPostExecute...");
}

为什么没有显示progressDialog?

谢谢。

【问题讨论】:

标签: java android android-asynctask progressdialog


【解决方案1】:

使用AsyncTask 时,您不应调用get(),因为get() 在当前线程(很可能是您的主线程)上运行doInBackground(),导致您的UI 冻结。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多