For the last few days I have been trying to create "lite" apps for services I use by writing webview applications in android studio using Java. The problem is that when I press the back button on the navigation bar, the apps exit to the launcher instead of returning to the previous webpage. ive tried using
@Override
public void onBackPressed()
{
if(app.canGoBack()){
app.goBack();
}else{
super.onBackPressed();
}
even though onBackPressed is deprecated to no avail. ive also tried
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction()== KeyEvent.ACTION_DOWN){
switch (keyCode){
case KeyEvent.KEYCODE_BACK:
if (app.canGoBack()) {
app.goBack();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
which again fixes nothing. im effectively posting this here as a last resort because nobody else on the entire internet seems to know whats going on and i wanna fix it :( im using the latest version of android studio on windows 11 21h2, writing in java with the latest sdk.