How must my WebViewClient be so all Websites that are not Google.com are loaded in an external WebView within it's own activity?
Thanks
How must my WebViewClient be so all Websites that are not Google.com are loaded in an external WebView within it's own activity?
Thanks
I dont know what you exactly want. You can define a webview in your layout and load a url in there.
View v = inflater.inflate(R.layout.fragment_webview, container, false);
WebView webView = (WebView) v.findViewById(R.id.webView);
webView.setWebViewClient(new DefaultWebClient());
webView.loadUrl("http://www.your.domain");
webView.requestFocus(View.FOCUS_DOWN);
If you want to make sure that only pages which are not starting with google are loaded into your webview, you may set a new WebViewClient() and override it like here:
wv.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
String url_new = view.getUrl();
if (url_new.toLowerCase().contains("google.com")) { .... do your stuff ... }
}
});