private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
} }
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new HelloWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://mydomain.com");
}
This is a very simple webview demo ( I followed a tutorial to write it). When a user loads up my application, this webview pops up and he's able to go on the internet inside it.
How do I "listen" for an event?
- When a URL contains "google.com"
- Or, when the HTML contains the word "google"
As the user is using my webview to browse the web, I'd like to listen to those things and then call a function when it happens.