[Android] 뒤로가기(BackButton) 두번 눌러서 앱 종료!

2014. 7. 31. 19:32Programming/Android

반응형

//BackButton 

 private final long FINSH_INTERVAL_TIME    = 2000;

private long backPressedTime        = 0;



@Override 

public void onBackPressed() {

long tempTime        = System.currentTimeMillis();

long intervalTime    = tempTime - backPressedTime;


if ( 0 <= intervalTime && FINSH_INTERVAL_TIME >= intervalTime ) {

super.onBackPressed(); 

else

backPressedTime = tempTime; 

Toast.makeText(getApplicationContext(),"두번 눌러",Toast.LENGTH_SHORT).show(); 


반응형