views:

823

answers:

1
  1. I load HTML data into WebView with loadDataWithBaseURL
  2. Do it one more time
  3. Execute the following code and instead of going back to the 1st page - whole app exits. What am I doing wrong here?

    public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && this.browser.canGoBack()) {
        this.browser.goBack();
        return true;
    }
    return super.onKeyDown(keyCode, event);
    

    }

Also - is it possible for WebView cache to survive Activity#onStop? Basically - if I close app and reopen - I want WebView to display last data that was loaded, currently - I'll get a blank screen and then have to reload same data again

+1  A: 

The problem is that load* does not create a new WebView, nor does it do anything special like create a history record, unfortunately.

You probably want call startActivity() and invoke a second activity for the second set of data.

Mike
My WebView is embedded into single activity, I guess I will have to monkey with history
DroidIn.net