Issue
On create of my activity I am firing a loading handler (whilst a spinner is shown), amongst other things in that handler code I call loadURL on three private WebView objects.
The purpose of this is to pre-cache these webpages, each it then shown dependent on a button touch event. The actual loading and displaying is working fine, except that sometimes (can't see a pattern yet) I (or my testers) get browser choice screen (such as Chrome / Firefox) for no reason.
So my first question is what would cause that, and how to prevent it from happening?
Otherwise how else would you perform the following:
- Pre-cache the result of three webpages (simple HTML, tables etc with no images).
- Dependent on a button touch display the result of the webpage in a layout on screen (same layout each time, so when button 2 is touched it's corresponding webpage replaces the previous one).
Solution
Never like answering my own questions, but as the only answer wasn't relevant to the question.
It seems that the problem was caused by a redirect, the webpage being loaded did not actually have a redirect it it, but the server was performing an internal redirect from a sub-domain. I got around the problem with the following code.
this.wvBasic.setWebViewClient(new WebViewClient() {
private String pendingUrl;
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (pendingUrl == null) {
pendingUrl = url;
}
}
@Override
public void onPageFinished(WebView view, String url) {
if (!url.equals(pendingUrl)) {
Log.d(TAG, "Detected HTTP redirect " + pendingUrl + "->" + url);
pendingUrl = null;
}
}
});
this.wvBasic.getSettings().setJavaScriptEnabled(false);
Answered By - melodiouscode
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.