FileDocCategorySizeDatePackage
WebViewClient.javaAPI DocAndroid 1.5 API8222Wed May 06 22:41:56 BST 2009android.webkit

WebViewClient

public class WebViewClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public voiddoUpdateVisitedHistory(WebView view, java.lang.String url, boolean isReload)
Notify the host application to update its visited links database.

param
view The WebView that is initiating the callback.
param
url The url being visited.
param
isReload True if this url is being reloaded.

    
public voidonFormResubmission(WebView view, android.os.Message dontResend, android.os.Message resend)
As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data.

param
view The WebView that is initiating the callback.
param
dontResend The message to send if the browser should not resend
param
resend The message to send if the browser should resend data

        dontResend.sendToTarget();
    
public voidonLoadResource(WebView view, java.lang.String url)
Notify the host application that the WebView will load the resource specified by the given url.

param
view The WebView that is initiating the callback.
param
url The url of the resource the WebView will load.

    
public voidonPageFinished(WebView view, java.lang.String url)
Notify the host application that a page has finished loading. This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet. To get the notification for the new Picture, use {@link WebView.PictureListener#onNewPicture}.

param
view The WebView that is initiating the callback.
param
url The url of the page.

    
public voidonPageStarted(WebView view, java.lang.String url, android.graphics.Bitmap favicon)
Notify the host application that a page has started loading. This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted one time for the main frame. This also means that onPageStarted will not be called when the contents of an embedded frame changes, i.e. clicking a link whose target is an iframe.

param
view The WebView that is initiating the callback.
param
url The url to be loaded.
param
favicon The favicon for this page if it already exists in the database.

    
public voidonReceivedError(WebView view, int errorCode, java.lang.String description, java.lang.String failingUrl)
Report an error to an activity. These errors come up from WebCore, and are network errors.

param
view The WebView that is initiating the callback.
param
errorCode The HTTP error code.
param
description A String description.
param
failingUrl The url that failed.

    
public voidonReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, java.lang.String host, java.lang.String realm)
Notify the host application to handle an authentication request. The default behavior is to cancel the request.

param
view The WebView that is initiating the callback.
param
handler The HttpAuthHandler that will handle the user's response.
param
host The host requiring authentication.
param
realm A description to help store user credentials for future visits.

        handler.cancel();
    
public voidonReceivedSslError(WebView view, SslErrorHandler handler, android.net.http.SslError error)
Notify the host application to handle a ssl certificate error request (display the error to the user and ask whether to proceed or not). The host application has to call either handler.cancel() or handler.proceed() as the connection is suspended and waiting for the response. The default behavior is to cancel the load.

param
view The WebView that is initiating the callback.
param
handler An SslErrorHandler object that will handle the user's response.
param
error The SSL error object.
hide
- hide this because it contains a parameter of type SslError, which is located in a hidden package.

        handler.cancel();
    
public voidonScaleChanged(WebView view, float oldScale, float newScale)
Notify the host application that the scale applied to the WebView has changed.

param
view he WebView that is initiating the callback.
param
oldScale The old scale factor
param
newScale The new scale factor

    
public voidonTooManyRedirects(WebView view, android.os.Message cancelMsg, android.os.Message continueMsg)
Notify the host application that there have been an excessive number of HTTP redirects. As the host application if it would like to continue trying to load the resource. The default behavior is to send the cancel message.

param
view The WebView that is initiating the callback.
param
cancelMsg The message to send if the host wants to cancel
param
continueMsg The message to send if the host wants to continue

        cancelMsg.sendToTarget();
    
public voidonUnhandledKeyEvent(WebView view, android.view.KeyEvent event)
Notify the host application that a key was not handled by the WebView. Except system keys, WebView always consumes the keys in the normal flow or if shouldOverrideKeyEvent returns true. This is called asynchronously from where the key is dispatched. It gives the host application an chance to handle the unhandled key events.

param
view The WebView that is initiating the callback.
param
event The key event.

    
public booleanshouldOverrideKeyEvent(WebView view, android.view.KeyEvent event)
Give the host application a chance to handle the key event synchronously. e.g. menu shortcut key events need to be filtered this way. If return true, WebView will not handle the key event. If return false, WebView will always handle the key event, so none of the super in the view chain will see the key event. The default behavior returns false.

param
view The WebView that is initiating the callback.
param
event The key event.
return
True if the host application wants to handle the key event itself, otherwise return false

        return false;
    
public booleanshouldOverrideUrlLoading(WebView view, java.lang.String url)
Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. If WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the url. If WebViewClient is provided, return true means the host application handles the url, while return false means the current WebView handles the url.

param
view The WebView that is initiating the callback.
param
url The url to be loaded.
return
True if the host application wants to leave the current WebView and handle the url itself, otherwise return false.

        return false;