Android 2.3 WebView goBackOrForward not working

I have a WebView in my application, and based on various conditions, I want to return to some element of the story. The resulting index is valid, although WebView does nothing (does not attack) in 2.3. It works in 4.1+.

private Integer getBackIndex(){
    WebBackForwardList list = webView.copyBackForwardList();
    Integer backi = null;
    for(int i=list.getSize()-1;i>=0;--i){
        String url = list.getItemAtIndex(i).getUrl();
        //select the appropriate index and set to backi
    }

    return backi;
}

private void goBack(){
    Integer backi = getBackIndex();
    Assert.assertNotNull(backi);
    WebBackForwardList list = webView.copyBackForwardList();
    Log.d("web","going "+String.valueOf(backi-list.getCurrentIndex()));
    webView.goBackOrForward(backi-list.getCurrentIndex());
}

The magazine confirms that we are returning 2 indexes, although nothing happens on my gingerbread device. Does this have to do anything with webView settings or is this a bug?

+4
source share

Source: https://habr.com/ru/post/1536789/


All Articles