xvxingxing 2015-11-03 06:26 采纳率: 0%
浏览 2667

progress dialog不显示

private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {

    public void onClick(View v) {
        if (Utils.isMonkeyRunning()) {
            return;
        }

        final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
                getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);

        if (pdbManager != null && !pdbManager.getOemUnlockEnabled()) {
            // if OEM unlock is enabled, this will be wiped during FR process.
            final ProgressDialog progressDialog = getProgressDialog();
            progressDialog.show();              


            // need to prevent orientation changes as we're about to go into
            // a long IO request, so we won't be able to access inflate resources on flash
            final int oldOrientation = getActivity().getRequestedOrientation();
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
            new AsyncTask<Void, Void, Void>() {   
                @Override
                protected Void doInBackground(Void... params) {
                    pdbManager.wipe();                                                                                              
                    return null;
                }

                @Override
                protected void onPostExecute(Void aVoid) {
                    progressDialog.hide();
                    getActivity().setRequestedOrientation(oldOrientation);          
                    doMasterClear();
                }
            }.execute();
        } else {
            doMasterClear();
        }
    }

    private ProgressDialog getProgressDialog() {
        final ProgressDialog progressDialog = new ProgressDialog(getActivity());
        progressDialog.setIndeterminate(true);
        progressDialog.setCancelable(false);
        progressDialog.setTitle(
                getActivity().getString(R.string.master_clear_progress_title));
        progressDialog.setMessage(
                getActivity().getString(R.string.master_clear_progress_text));
        return progressDialog;
    }
}

    以上的代码是5.1.1版本恢复出厂设置的代码,现在会走 new AsyncTask<Void, Void, Void>()这里的代码,运行pdbManager.wipe();  问题是:progressDialog.show()有时候会显示进度对话框,有时候不显示,有时候显示的时间长,有时候时间短,关于为什么不显示对话框,有人帮忙解释一下吗?请教该如何修改,才能保证会显示呢?
  • 写回答

1条回答 默认 最新

  • bdmh 移动开发领域优质创作者 2015-11-03 06:34
    关注

    应该是onPostExecute中的hide直接给隐藏了

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料