Created
July 15, 2015 02:15
-
-
Save cuber5566/a399d22142bd6a390014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isExit = false; | |
private CountDownTimer countDownTimer; | |
@Override | |
public void onBackPressed() { | |
if (webView.canGoBack()) { | |
webView.goBack(); | |
} else { | |
if (!isExit) { | |
isExit = true; | |
Toast.makeText(this, getResources().getString(R.string.dialog_back_exit_app), Toast.LENGTH_SHORT).show(); | |
countDownTimer = new CountDownTimer(2_000, 2_000) { | |
@Override | |
public void onFinish() { | |
isExit = false; | |
} | |
@Override | |
public void onTick(long millisUntilFinished) { | |
} | |
}.start(); | |
} else { | |
countDownTimer.cancel(); | |
finish(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment