I am working with Cordova and the inAppBrowser plugin for Android
https://github.com/apache/cordova-plugin-inappbrowser
I am trying to control the hardware back button for Android in Java file
InAppBrowserDialog.java
public void onBackPressed() {
if (this.inAppBrowser == null) {
this.dismiss();
} else {
if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
// this.inAppBrowser.goBack();
} else {
// this.inAppBrowser.closeDialog();
}
}
}
}
I do not want it to "goBack" or "closeDialog", I want it to "hide", like you can call it on the Cordova Javascript side
https://github.com/apache/cordova-plugin-inappbrowser#inappbrowserhide
ref.hide();
Hide is ideal so I can call .show if I want without loading the entire page, which is what would happen if I just closed it.
I am looking for a Java command such as
this.inAppBrowser.hide();
But I can't seem to find it.
====== UPDATE ====================
So the Java code linked to the Codrova .hide Javascript is here
https://github.com/apache/cordova-plugin-inappbrowser/blob/8bdbd18d1619e25cf8bdedadf6448ef40b21ea7c/src/android/InAppBrowser.java#L329-L341
else if (action.equals("hide")) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (dialog != null && !cordova.getActivity().isFinishing()) {
dialog.hide();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
pluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(pluginResult);
}
I just can't figure out how to call this Java function from the Java back button function.
from Cordova inAppBrowser Hide / Show in Java Android
No comments:
Post a Comment