5
submitted 1 week ago* (last edited 1 week ago) by FeelThePower@lemmy.dbzer0.com to c/android_dev@programming.dev

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.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here
this post was submitted on 11 May 2026
5 points (100.0% liked)

Android Development

689 readers
1 users here now

Welcome to the programming.dev Android development community!

The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License

founded 2 years ago
MODERATORS