private static Boolean isQuit = false;
成都創(chuàng)新互聯(lián)10多年成都企業(yè)網(wǎng)站定制服務(wù);為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁設(shè)計(jì)及高端網(wǎng)站定制服務(wù),成都企業(yè)網(wǎng)站定制及推廣,對(duì)集裝箱等多個(gè)領(lǐng)域擁有豐富的營銷推廣經(jīng)驗(yàn)的網(wǎng)站建設(shè)公司。
Timer timer = new Timer();
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (isQuit == false) {
isQuit = true;
Toast.makeText(getBaseContext(), "再按一次返回鍵退出程序", Toast.LENGTH_SHORT).show();
TimerTask task = null;
task = new TimerTask() {
@Override
public void run() {
isQuit = false;
}
};
timer.schedule(task, 2000);
} else {
finish();
System.exit(0);
}
}
return false;
}