Reputation: 190
I load the url in the WebView but, when the user click some button the new url is loaded in the android browser not in my webview. What should I do?
Thanks in advance.
Upvotes: 11
Views: 13322
Reputation: 3783
You have to use both WebViewClient and WebChromeClient.
WebChromeClient allows you to get loading progress, for example, whereas WebViewClient will allow you overriding shouldOverrideUrlLoading().
From the WebView page doc:
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
Upvotes: 20
Reputation: 1701
webchromeClient does not seem to have this ability. Seems silly that WebViewClient can and WebChromeClient can't.
Upvotes: 0
Reputation: 2795
just go through
http://developer.android.com/reference/android/webkit/WebView.html
you will come to know how to use webchromeClient.....
tell me if this help for you...
Upvotes: -3