在牛轧糖及更高版本上阻止UI

时间:2019-02-06 10:12:46

标签: java android handler

以下代码适用于低于牛轧糖版本的代码。 在更高版本上不起作用。

 handler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    super.handleMessage(msg);

                    switch (msg.what) {
                        case MSG_SYS_CACHE_BEGIN:
                            break;

                        case MSG_PROCESS_BEGIN:
                            break;

                        case MSG_PROCESS_POS:
                            mHeaderView.mProgress.setText("\n" + "Scanning:" + ((JunkInfo) msg.obj).mPackageName);
                            mHeaderView.mSize.setText(CleanUtil.formatShortFileSize(Junk_New.this, getTotalSize()));
                            break;

                        case MSG_PROCESS_FINISH:
                            mIsProcessScanFinish = true;
                            checkScanFinish();
                            break;

                        case MSG_PROCESS_CLEAN_FINISH:
                            mIsProcessCleanFinish = true;
                            checkCleanFinish();
                            break;

                        case MSG_OVERALL_BEGIN:
                            break;

                        case MSG_OVERALL_POS:
                            mHeaderView.mProgress.setText("\n" + "Scanning:" + ((JunkInfo) msg.obj).mPath);
                            mHeaderView.mSize.setText(CleanUtil.formatShortFileSize(Junk_New.this, getTotalSize()));
                            break;

                        case MSG_OVERALL_FINISH:
                            mIsOverallScanFinish = true;
                            checkScanFinish();
                            break;

                        case MSG_OVERALL_CLEAN_FINISH:
                            mIsOverallCleanFinish = true;
                            checkCleanFinish();
                            break;
                    }
                }
            };

Ui卡在屏幕上,无济于事。 我无法使用以下方式在ui线程和后台线程之间进行通信 HandlerThread 方法。

0 个答案:

没有答案