Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit c99818a

Browse files
committed
Merge pull request #167 from wuhengzhi/master
Fix the Cordova app exit issue.
2 parents ed2a3ce + 4d2d0cc commit c99818a

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

framework/src/org/apache/cordova/CordovaActivity.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,13 @@ public boolean onKeyUp(int keyCode, KeyEvent event)
11151115
public boolean onKeyDown(int keyCode, KeyEvent event)
11161116
{
11171117
//Determine if the focus is on the current view or not
1118-
if (appView != null && appView.getFocusedChild() != null && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
1119-
return appView.onKeyDown(keyCode, event);
1118+
if (appView != null && appView.getFocusedChild() != null &&
1119+
(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
1120+
if (!appView.onKeyDown(keyCode, event)) {
1121+
getActivity().finish();
1122+
return false;
1123+
}
1124+
return true;
11201125
}
11211126
else
11221127
return super.onKeyDown(keyCode, event);

framework/src/org/apache/cordova/CordovaWebView.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,6 @@ public boolean dispatchKeyEvent(KeyEvent event)
675675
return true;
676676
}
677677
// If not, then invoke default behavior
678-
else {
679-
//this.activityState = ACTIVITY_EXITING;
680-
//return false;
681-
// If they hit back button when app is initializing, app should exit instead of hang until initialization (CB2-458)
682-
this.cordova.getActivity().finish();
683-
return false;
684-
}
685678
}
686679
}
687680
}

0 commit comments

Comments
 (0)