private long lastTime;
@Override //双击退出
public void onBackPressed(){
long currentTime = System.currentTimeMillis();
if (currentTime - lastTime < 2 * 1000) {
super.onBackPressed();
} else {
Toast.makeText(this, "请再按一次", Toast.LENGTH_SHORT).show();
lastTime = currentTime;
}
}
@Override //双击退出
public void onBackPressed(){
long currentTime = System.currentTimeMillis();
if (currentTime - lastTime < 2 * 1000) {
super.onBackPressed();
} else {
Toast.makeText(this, "请再按一次", Toast.LENGTH_SHORT).show();
lastTime = currentTime;
}
}