方法一:重写onBackPressed()方法
@Override
public void onBackPressed() {
if (mBackPressed+TIME_INTERVAL>System.currentTimeMillis()){
super.onBackPressed();
return;
}else {
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
}
mBackPressed = System.currentTimeMillis();
}
当然也可以写个其他的定时器来实现,无需判断onKeyDown()和onKeyUp()
So Esay!!!