Thursday, April 22, 2021

Android WebView how to do stack navigation



@Override

public void onBackPressed() {

    if (web.copyBackForwardList().getCurrentIndex() > 0) {

        web.goBack();

    }

    else {

        // Your exit alert code, or alternatively line below to finish

        super.onBackPressed(); // finishes activity

    }

}


references:

https://stackoverflow.com/questions/16941930/pressing-back-button-exits-the-app-instead-of-navigating-backwards-in-the-webvie


No comments:

Post a Comment