android webview and loadData, can i get the back button to return to generated content?
Asked Answered
G

1

7

I have an android webview that displays generated content with loadDataWithBaseURL. Looks great. However, if i follow a link and then hit the back button I get a blank page where I'd like to see my generated content.

does anyone know how I can use the back button to return to my generated content?

Giraudoux answered 7/7, 2011 at 5:38 Comment(0)
W
0

Try this:

mWebView.setOnKeyListener(new OnKeyListener() {
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        switch(keyCode)
        {
            case KeyEvent.KEYCODE_BACK:
                if(mWebView.canGoBack() == true){
                    mWebView.goBack();
                    return true;
                } else
                    return false;   
                }

                return false;
            }
        });
Waldowaldon answered 12/11, 2012 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.