为什么DialogFragment没有显示?

时间:2017-03-10 02:25:08

标签: java android

要求是当我打开开关按钮时,将显示对话框并启动指纹验证。在FingerprintActivity.java中,对话框工作正常,但在SettingListActivity.java中,它没有显示!代码是一样的,为什么没有显示?这是我的问题,提前谢谢!

FingerprintActivity.java

private void initDialog() {
    //show dialog to start fingerprint auth
    FingerPrintDialog fpDialog = new FingerPrintDialog();
    fpDialog.show(getFragmentManager(), "fpDialog");
    startFingerprintRecognitionUnlockScreen();
}

SettingListActivity.java

if (position == 3) {
    vh.switchBtn.setChecked(ConnData.isFingerPrint);
    final SharedPreferences.Editor fingerStatus = getSharedPreferences("finger", MODE_PRIVATE).edit();
    vh.switchBtn.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            clickType = 1;
            isFingerOpen = isChecked;
            //switchbutton status
            if (isFingerOpen) {
                //hasn't fingerprint
                if (!manager.hasEnrolledFingerprints()) {
                    new DialogMgr(SettingListActivity.this.getParent(), R.string.title_information, R.string.message_sure_start_finger, "") {
                        @Override
                        protected void onclick(View v) {
                            //intent to the system settings
                            startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
                            vh.switchBtn.setChecked(false);
                            super.onclick(v);
                        }

                        @Override
                        protected void oncancel(View v) {
                            //close button
                            vh.switchBtn.setChecked(false);
                            super.oncancel(v);
                        }
                    };
                } else {
                    //show dialog to start fingerprint auth 
                    FingerPrintDialog fpDialog = new FingerPrintDialog();
                    fpDialog.show(getFragmentManager(), "fpOpenDialog");
                    mFingerprintCore = new FingerprintCore(SettingListActivity.this);
                    mFingerprintCore.setFingerprintManager(mResultListener);
                    mKeyguardLockScreenManager = new KeyguardLockScreenManager(SettingListActivity.this);
                    mFingerprintCore.startAuthenticate();

                    //open fingerprint and close gesture recognition
                    final LockPatternUtils lockPatternUtils = new LockPatternUtils(SettingListActivity.this);
                    lockPatternUtils.clearLock();
                    lockPatternUtils.saveLockFlag(false);
                    vh.switchBtn.setChecked(isFingerOpen);
                    fingerStatus.putString("isFingerPrint", "open");
                    fingerStatus.commit();
                }
            }
        }
    });
}

0 个答案:

没有答案