1

I've been searching, but I can't find a code that works with mine, I've found some similar questions, but the others not work with my "after loading" code.

What I need is search for a text, if exist show the page normally (do nothing, I mean, let continue), if not exist, show a html message on the same webview with this code:

String MsgError = "<html><body><h1 style='color:#FF0000'>Error</h1><br /><a style='color:#000000'>An error occurred while page is loading, please try again later.</a></body></html>";
mWebView.loadData(MsgError, "text/html", "UTF-8");

I have to find a text like this one:

Text

This is my "after loading" code:

@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    view.clearCache(true);
}

Thanks in advanced.

Minion
  • 2,497
  • 4
  • 27
  • 29

1 Answers1

3

Perhaps it may be interesting to look here, where somebody explains how to extract the HTML as a string from a webview. You could perform a String.matches() on that string. Depending on the result you get, you can either let the WebView be, or redirect it to your own, custom error page.

Community
  • 1
  • 1
Vic V
  • 1,080
  • 2
  • 12
  • 31