Android Settings Dialog does not allow physical back key to exit

Sometimes when you need to run for a time-consuming task, requiring the emergence of a wait (that is, a small white circle that has been transferred) Dialog to tell users now need to wait a bit, because the time-consuming thing to do, but can be set to prevent Dialog click outside cancel Dialog, I forgot physical return key can also be canceled Dialog, so online searching for information are summarized below.


1, directly  

dia_wait.setCancelable(false);

This method is the most simple and crude and best use.

2, onKeyDown shield (not so good)

3, only set setOnKeyListener monitor above do not recommend to the appropriate Dialog.

Published 124 original articles · won praise 141 · views 160 000 +

Guess you like

Origin blog.csdn.net/weixin_36838630/article/details/79607773