Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ public void onDestroy() {

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// If it wasn't the Back key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
if (keyCode != KeyEvent.KEYCODE_BACK) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not to be the best approach as it's colliding with the rest of its code and its purpose. Instead of doing this you should try another approach from the app itself on how it handles the back key.

return super.onKeyDown(keyCode, event);
}

if (SystemClock.elapsedRealtime() - lastBackClick > 2000) {
lastBackClick = SystemClock.elapsedRealtime();
Toast.makeText(this, "Click again to close the app", Toast.LENGTH_LONG).show();
Expand Down
Loading