1 year ago
#385807
Martin De Beer
My onBackPressed seems to be working in reverse
I have been struggling with this issue for about a day now. When I press the back button on my phone it runs my code backwards. Can anyone perhaps tell me why this happens and how I will fix it??
public void onBackPressed() {
displayToast("Pressed Back"); // Executed last
superWebView.evaluateJavascript("window.sessionStorage.getItem('windowActive')",
new ValueCallback<String>() {
@Override
public void onReceiveValue(String value)
{
if ("logo.html".equals(value)) { // Gets skipped
displayToast("Press back again to exit");
new AlertDialog.Builder(mAppContext)
.setTitle("Closing Program")
.setMessage("Are you sure you want to exit Vertex?")
.setPositiveButton("Yes", (dialog, which) -> finish())
.setNegativeButton("No", null)
.show();
} else {
displayToast("Default"); // This executes first
superWebView.loadUrl("javascript:goBack()");
}
}
});
}
java
android
webview
android-webview
0 Answers
Your Answer