Implementation code of exit confirmation box in Android

This is achieved by blocking and rewriting the operation of the fallback key: when the fallback key is pressed, a prompt box will pop up to select whether to exit. If yes, the exit code will be executed, otherwise nothing will be done.

Rewrite in mianactivity:

By adding this code to an Android program, you can get the final fallback key, as shown in the figure:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>