Android implements pressing the return key twice to exit the program (two methods)

Android implements pressing the return key twice to exit the program (two methods)

The first method:

The second method:

The principle is very simple: define a TimerTask timer and an identifier isexit whether to exit the program. Press the return key for the first time, assign the isexit flag to true, start the timer TimerTask task, and assign the isexit flag to false two seconds later. Therefore, the user presses the return key again within these two seconds to exit the program. Otherwise, the timer TimerTask task executes, and the flag is false. The principle is so simple~

Thank you for reading, hope to help you, thank you for your support to this site!

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
分享
二维码
< <上一篇
下一篇>>