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?

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Matthew Kime
  • 754
  • 1
  • 6
  • 15

1 Answers1

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;
            }
        });
Ifrit
  • 6,791
  • 8
  • 50
  • 79