Exit event not firing if hardware back button is used.
Exit event fires when the close button is used but not when back button is used to exit the browser.
You mean Hardware back button? Am 25.09.2015 16:28 schrieb "Akshar Patel" [email protected]:
Exit event fires when the close button is used but not when back button is used to exit the browser.
— Reply to this email directly or view it on GitHub https://github.com/Shoety/cordova-plugin-inappbrowserxwalk/issues/11.
Yes @ClaasBrueggemann.
pls how do i remove the close button from the browser and also prevent users from copying my content.. because i noticed that when the user try to copy the content, another search option shows which feels awkward.. please help. thank you
+1 "Hardware back button"
+1 "Hardware back button"
This is a pretty serious issue. Users can use the hardware back button, which hides the browser, but does not exit. There is no notification that the browser is no longer visible. I'd help if I better understood Android internals...but that's why I use cordova ;-)
After some research and experimentation, it seems that preventing the hardware back button from hiding the browser is as simple as adding this code to BrowserDialog.java inside class BrowserDialog:
@Override
public void onBackPressed() {
return;
}
This still allows use of the back button to move backwards in the browser's history, but once the earliest URL is reached, it does nothing. I'm not sure if I should create a pull request as this probably wants a setting or something, but adding this code to our fork of the plugin seems to work.
I fixed this by adding the following code to the InAppBrowserXwalk.java file:
dialog = new BrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
try {
JSONObject obj = new JSONObject();
obj.put("type", "exit");
PluginResult result = new PluginResult(PluginResult.Status.OK, obj);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
} catch (JSONException ex) {}
}
});
This way the exit event is fired when pressing the hardware back button and you can close the app in javascript if you like.
Duplicate of #23 which actually fixed in last version