---
title: "如何屏蔽back键，当点击back键时Dialog对话框不消失"
author: "Mr.Cheney"
date: "2015-08-21T11:12:29Z"
tags: []
categories: ["移动开发"]
slug: "back-back-dialog"
draft: false
lastmod: "2015-08-21T11:13:36Z"
id: 2237031
url: "https://mr-cheney.iteye.com/blog/2237031"
---

```
mSaveingProgressDialog.setOnKeyListener(mDialogOnKeylistener);    

DialogInterface.OnKeyListener mDialogOnKeylistener = new DialogInterface.OnKeyListener(){
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (mSaveing) {
                if (KeyEvent.KEYCODE_BACK == keyCode) {
                    return true;
                }
            }
            return false;
        }
    } ;
```