public class

WebView

extends FrameLayout
implements View.OnLongClickListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.tencent.smtt.sdk.WebView

Summary

Nested Classes
class WebView.HitTestResult Hit test result  
class WebView.WebViewTransport Transportation object for returning WebView across thread boundaries. 
Constants
String SCHEME_GEO URI scheme for map address.
String SCHEME_MAILTO URI scheme for email address.
String SCHEME_TEL URI scheme for telephone number.
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
WebView(Context context)
Constructs a new WebView with an Activity Context object.
WebView(Context context, AttributeSet attrs)
Constructs a new WebView with layout parameters.
WebView(Context context, AttributeSet attrs, int defStyle)
Constructs a new WebView with layout parameters and a default style.
Public Methods
void addJavascriptInterface(Object obj, String interfaceName)
Injects the supplied Java object into this WebView.
void addView(View child)
Adds a child view to webview.
boolean canGoBack()
Gets whether this WebView has a back history item.
boolean canGoBackOrForward(int steps)
Gets whether the page can go back or forward the given number of steps.
boolean canGoForward()
Gets whether this WebView has a forward history item.
void clearCache(boolean includeDiskFiles)
Clears the resource cache.
void clearFormData()
Removes the autocomplete popup from the currently focused form field, if present.
void clearHistory()
Tells this WebView to clear its internal back/forward list.
void clearMatches()
Clears the highlighting surrounding text matches created by findAllAsync(String).
void clearSslPreferences()
Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.
WebBackForwardList copyBackForwardList()
Gets the WebBackForwardList for this WebView.
void destroy()
void documentHasImages(Message response)
Queries the document to see if it contains any image references.
void evaluateJavascript(String script, ValueCallback<String> resultCallback)
Asynchronously evaluates JavaScript in the context of the currently displayed page.
void findAllAsync(String find)
Finds all instances of find on the page and highlights them, asynchronously.
void findNext(boolean forward)
Highlights and scrolls to the next match found by findAllAsync(String), wrapping around page boundaries as necessary.
SslCertificate getCertificate()
Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure).
int getContentHeight()
Gets the height of the HTML content.
static String getCrashExtraMessage(Context context)
Get extra message of tbs core, add this message to crash report to detect tbs core reason
static PackageInfo getCurrentWebViewPackage()
If WebView has already been loaded into the current process this method will return the package that was used to load it.
Bitmap getFavicon()
Gets the favicon for the current page.
WebView.HitTestResult getHitTestResult()
Gets a HitTestResult based on the current cursor node.
String[] getHttpAuthUsernamePassword(String host, String realm)
Retrieves HTTP authentication credentials for a given host and realm from the WebViewDatabase instance.
boolean getIsX5Core()
Judge the webview if is x5
String getOriginalUrl()
Gets the original URL for the current page.
int getProgress()
Gets the progress for the current page.
WebSettings getSettings()
Gets the WebSettings object used to control the settings for this WebView.
IX5WebSettingsExtension getSettingsExtension()
Get IX5WebSettingsExtension from webview, app can set extension settings for webview
static int getTbsCoreVersion(Context context)
get Tbs(X5) core version
static int getTbsSDKVersion(Context context)
get Tbs SDK version
String getTitle()
Gets the title for the current page.
String getUrl()
Gets the URL for the current page.
View getView()
Get real wrapped WebView
WebChromeClient getWebChromeClient()
Gets the chrome handler.
IX5WebChromeClientExtension getWebChromeClientExtension()
Get IX5WebChromeClientExtension
WebViewClient getWebViewClient()
Gets the WebViewClient.
IX5WebViewClientExtension getWebViewClientExtension()
Get IX5WebViewClientExtension
IX5WebViewExtension getX5WebViewExtension()
Get IX5WebViewExtension
void goBack()
Goes back in the history of this WebView.
void goBackOrForward(int steps)
Goes to the history item that is the number of steps away from the current item.
void goForward()
Goes forward in the history of this WebView.
boolean isPrivateBrowsingEnabled()
Gets whether private browsing is enabled in this WebView.
void loadData(String data, String mimeType, String encoding)
Loads the given data into this WebView using a 'data' scheme URL.
void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl)
Loads the given data into this WebView, using baseUrl as the base URL for the content.
void loadUrl(String url)
Loads the given URL.
void loadUrl(String url, Map<String, String> extraHeaders)
Loads the given URL with the specified additional HTTP headers.
void onPause()
Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation.
void onResume()
Resumes a WebView after a previous call to onPause().
boolean pageDown(boolean bottom)
Scrolls the contents of this WebView down by half the page size.
boolean pageUp(boolean top)
Scrolls the contents of this WebView up by half the view size.
void pauseTimers()
Pauses all layout, parsing, and JavaScript timers for all WebViews.
void postUrl(String url, byte[] postData)
Loads the URL with postData using "POST" method into this WebView.
void reload()
Reloads the current URL.
void removeJavascriptInterface(String interfaceName)
Removes a previously injected Java object from this WebView.
void removeView(View view)
Remove view from webview
void requestFocusNodeHref(Message hrefMsg)
Requests the anchor or image element URL at the last tapped point.
void requestImageRef(Message msg)
Requests the URL of the image last touched by the user.
WebBackForwardList restoreState(Bundle inState)
Restores the state of this WebView from the given Bundle.
void resumeTimers()
Resumes all layout, parsing, and JavaScript timers for all WebViews.
WebBackForwardList saveState(Bundle outState)
Saves the state of this WebView used in android.app.Activity#onSaveInstanceState.
void saveWebArchive(String filename)
Saves the current view as a web archive.
void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback)
Saves the current view as a web archive.
void setBackgroundColor(int color)
Sets the background color for this WebView.
static void setDataDirectorySuffix(String suffix)
Define the directory used to store WebView data for the current process.
void setDownloadListener(DownloadListener listener)
Registers the interface to be used when content can not be handled by the rendering engine, and should be downloaded instead.
void setFindListener(IX5WebViewBase.FindListener listener)
Registers the listener to be notified as find-on-page operations progress.
void setHttpAuthUsernamePassword(String host, String realm, String username, String password)
Stores HTTP authentication credentials for a given host and realm to the WebViewDatabase instance.
void setInitialScale(int scaleInPercent)
Sets the initial scale for this WebView.
void setNetworkAvailable(boolean networkUp)
Informs WebView of the network state.
void setOnLongClickListener(View.OnLongClickListener l)
Register a callback to be invoked when this WebView is clicked and held.
void setOnTouchListener(View.OnTouchListener onTouchListener)
Register a callback to be invoked when a touch event is sent to this view.
void setVisibility(int visibility)
Set the visibility state of this WebView.
void setWebChromeClient(WebChromeClient client)
Sets the chrome handler.
void setWebChromeClientExtension(IX5WebChromeClientExtension client)
Set IX5WebChromeClientExtension for webview, x5 will call the relevant interface in some scene,
static void setWebContentsDebuggingEnabled(boolean enabled)
Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application.
void setWebViewCallbackClient(WebViewCallbackClient client)
Set WebViewCallbackClient for webview, Special callback for app event processing
void setWebViewClient(WebViewClient client)
Sets the WebViewClient that will receive various notifications and requests.
void setWebViewClientExtension(IX5WebViewClientExtension client)
Set IX5WebViewClientExtension for webview
void stopLoading()
Stops the current load.
boolean zoomIn()
Performs zoom in in this WebView.
boolean zoomOut()
Performs zoom out in this WebView.
Protected Methods
void onDetachedFromWindow()
void onSizeChanged(int w, int h, int oldw, int oldh)
void onVisibilityChanged(View changedView, int visibility)
called when visibility changed
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.View.OnLongClickListener
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Constants

public static final String SCHEME_GEO

URI scheme for map address.

Constant Value: "geo:0,0?q="

public static final String SCHEME_MAILTO

URI scheme for email address.

Constant Value: "mailto:"

public static final String SCHEME_TEL

URI scheme for telephone number.

Constant Value: "tel:"

Public Constructors

public WebView (Context context)

Constructs a new WebView with an Activity Context object.

Note: WebView should always be instantiated with an Activity Context. If instantiated with an Application Context, WebView will be unable to provide several features, such as JavaScript dialogs and autofill.

Parameters
context an Activity Context to access application assets

public WebView (Context context, AttributeSet attrs)

Constructs a new WebView with layout parameters.

Parameters
context an Activity Context to access application assets
attrs an AttributeSet passed to our parent

public WebView (Context context, AttributeSet attrs, int defStyle)

Constructs a new WebView with layout parameters and a default style.

Parameters
context an Activity Context to access application assets
attrs an AttributeSet passed to our parent
defStyle an attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

Public Methods

public void addJavascriptInterface (Object obj, String interfaceName)

Injects the supplied Java object into this WebView.

Parameters
obj the Java object to inject into this WebView's JavaScript context. null values are ignored.
interfaceName the name used to expose the object in JavaScript

public void addView (View child)

Adds a child view to webview.

Parameters
child view to add

public boolean canGoBack ()

Gets whether this WebView has a back history item.

Returns
  • true if this WebView has a back history item

public boolean canGoBackOrForward (int steps)

Gets whether the page can go back or forward the given number of steps.

Parameters
steps the negative or positive number of steps to move the history

public boolean canGoForward ()

Gets whether this WebView has a forward history item.

Returns
  • true if this WebView has a forward history item

public void clearCache (boolean includeDiskFiles)

Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used.

Parameters
includeDiskFiles if false, only the RAM cache is cleared

public void clearFormData ()

Removes the autocomplete popup from the currently focused form field, if present. Note this only affects the display of the autocomplete popup, it does not remove any saved form data from this WebView's store. To do that, use clearFormData().

public void clearHistory ()

Tells this WebView to clear its internal back/forward list.

public void clearMatches ()

Clears the highlighting surrounding text matches created by findAllAsync(String).

public void clearSslPreferences ()

Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.

public WebBackForwardList copyBackForwardList ()

Gets the WebBackForwardList for this WebView. This contains the back/forward list for use in querying each item in the history stack. This is a copy of the private WebBackForwardList so it contains only a snapshot of the current state. Multiple calls to this method may return different objects. The object returned from this method will not be updated to reflect any new state.

public void destroy ()

public void documentHasImages (Message response)

Queries the document to see if it contains any image references. The message object will be dispatched with arg1 being set to 1 if images were found and 0 if the document does not reference any images.

Parameters
response the message that will be dispatched with the result

public void evaluateJavascript (String script, ValueCallback<String> resultCallback)

Asynchronously evaluates JavaScript in the context of the currently displayed page. If non-null, |resultCallback| will be invoked with any result returned from that execution. This method must be called on the UI thread and the callback will be made on the UI thread.

Compatibility note. Applications targeting android.os.Build.VERSION_CODES#N or later, JavaScript state from an empty WebView is no longer persisted across navigations like loadUrl(String). For example, global variables and functions defined before calling loadUrl(String) will not exist in the loaded page. Applications should use addJavascriptInterface(Object, String) instead to persist JavaScript objects across navigations.

Parameters
script the JavaScript to execute.
resultCallback A callback to be invoked when the script execution completes with the result of the execution (if any). May be null if no notification of the result is required.

public void findAllAsync (String find)

Finds all instances of find on the page and highlights them, asynchronously. Notifies any registered IX5WebViewBase.FindListener. Successive calls to this will cancel any pending searches.

Parameters
find the string to find.

public void findNext (boolean forward)

Highlights and scrolls to the next match found by findAllAsync(String), wrapping around page boundaries as necessary. Notifies any registered IX5WebViewBase.FindListener. If findAllAsync(String) has not been called yet, or if clearMatches() has been called since the last find operation, this function does nothing.

Parameters
forward the direction to search

public SslCertificate getCertificate ()

Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure).

Returns
  • the SSL certificate for the main top-level page

public int getContentHeight ()

Gets the height of the HTML content.

Returns
  • the height of the HTML content

public static String getCrashExtraMessage (Context context)

Get extra message of tbs core, add this message to crash report to detect tbs core reason

Parameters
context app context

public static PackageInfo getCurrentWebViewPackage ()

If WebView has already been loaded into the current process this method will return the package that was used to load it. Otherwise, the package that would be used if the WebView was loaded right now will be returned; this does not cause WebView to be loaded, so this information may become outdated at any time. The WebView package changes either when the current WebView package is updated, disabled, or uninstalled. It can also be changed through a Developer Setting. If the WebView package changes, any app process that has loaded WebView will be killed. The next time the app starts and loads WebView it will use the new WebView package instead.

Returns
  • the current WebView package, or null if there is none.

public Bitmap getFavicon ()

Gets the favicon for the current page. This is the favicon of the current page until WebViewClient.onReceivedIcon is called.

Returns
  • the favicon for the current page

public WebView.HitTestResult getHitTestResult ()

Gets a HitTestResult based on the current cursor node. If a HTML::a tag is found and the anchor has a non-JavaScript URL, the HitTestResult type is set to SRC_ANCHOR_TYPE and the URL is set in the "extra" field. If the anchor does not have a URL or if it is a JavaScript URL, the type will be UNKNOWN_TYPE and the URL has to be retrieved through requestFocusNodeHref(Message) asynchronously. If a HTML::img tag is found, the HitTestResult type is set to IMAGE_TYPE and the URL is set in the "extra" field. A type of SRC_IMAGE_ANCHOR_TYPE indicates an anchor with a URL that has an image as a child node. If a phone number is found, the HitTestResult type is set to PHONE_TYPE and the phone number is set in the "extra" field of HitTestResult. If a map address is found, the HitTestResult type is set to GEO_TYPE and the address is set in the "extra" field of HitTestResult. If an email address is found, the HitTestResult type is set to EMAIL_TYPE and the email is set in the "extra" field of HitTestResult. Otherwise, HitTestResult type is set to UNKNOWN_TYPE.

public String[] getHttpAuthUsernamePassword (String host, String realm)

Retrieves HTTP authentication credentials for a given host and realm from the WebViewDatabase instance.

Parameters
host the host to which the credentials apply
realm the realm to which the credentials apply
Returns
  • the credentials as a String array, if found. The first element is the username and the second element is the password. null if no credentials are found.

public boolean getIsX5Core ()

Judge the webview if is x5

Returns
  • true for x5, false for sys

public String getOriginalUrl ()

Gets the original URL for the current page. This is not always the same as the URL passed to WebViewClient.onPageStarted because although the load for that URL has begun, the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested.

Returns
  • the URL that was originally requested for the current page

public int getProgress ()

Gets the progress for the current page.

Returns
  • the progress for the current page between 0 and 100

public WebSettings getSettings ()

Gets the WebSettings object used to control the settings for this WebView.

Returns
  • a WebSettings object that can be used to control this WebView's settings

public IX5WebSettingsExtension getSettingsExtension ()

Get IX5WebSettingsExtension from webview, app can set extension settings for webview

Returns
  • the IX5WebSettingsExtension

public static int getTbsCoreVersion (Context context)

get Tbs(X5) core version

Returns
  • core version

public static int getTbsSDKVersion (Context context)

get Tbs SDK version

Returns
  • Tbs SDK version

public String getTitle ()

Gets the title for the current page. This is the title of the current page until WebViewClient.onReceivedTitle is called.

Returns
  • the title for the current page

public String getUrl ()

Gets the URL for the current page. This is not always the same as the URL passed to WebViewClient.onPageStarted because although the load for that URL has begun, the current page may not have changed.

Returns
  • the URL for the current page

public View getView ()

Get real wrapped WebView

Returns
  • real WebView

public WebChromeClient getWebChromeClient ()

Gets the chrome handler.

Returns
  • the WebChromeClient, or null if not yet set

public IX5WebChromeClientExtension getWebChromeClientExtension ()

Get IX5WebChromeClientExtension

Returns
  • the IX5WebChromeClientExtension, or not if not set

public WebViewClient getWebViewClient ()

Gets the WebViewClient.

Returns
  • the WebViewClient, or a default client if not yet set

public IX5WebViewClientExtension getWebViewClientExtension ()

Get IX5WebViewClientExtension

Returns
  • the IX5WebViewClientExtension, or not if not set

public IX5WebViewExtension getX5WebViewExtension ()

Get IX5WebViewExtension

Returns
  • the IX5WebViewExtension

public void goBack ()

Goes back in the history of this WebView.

public void goBackOrForward (int steps)

Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.

Parameters
steps the number of steps to take back or forward in the back forward list

public void goForward ()

Goes forward in the history of this WebView.

public boolean isPrivateBrowsingEnabled ()

Gets whether private browsing is enabled in this WebView.

public void loadData (String data, String mimeType, String encoding)

Loads the given data into this WebView using a 'data' scheme URL.

Parameters
data a String of data in the given encoding
mimeType the MIME type of the data, e.g. 'text/html'.
encoding the encoding of the data

public void loadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl)

Loads the given data into this WebView, using baseUrl as the base URL for the content. The base URL is used both to resolve relative URLs and when applying JavaScript's same origin policy. The historyUrl is used for the history entry.

Parameters
baseUrl the URL to use as the page's base URL. If null defaults to 'about:blank'.
data a String of data in the given encoding
mimeType the MIME type of the data, e.g. 'text/html'.
encoding the encoding of the data
historyUrl the URL to use as the history entry. If null defaults to 'about:blank'. If non-null, this must be a valid URL.

public void loadUrl (String url)

Loads the given URL.

Also see compatibility note on evaluateJavascript(String, ValueCallback).

Parameters
url the URL of the resource to load

public void loadUrl (String url, Map<String, String> extraHeaders)

Loads the given URL with the specified additional HTTP headers.

Also see compatibility note on evaluateJavascript(String, ValueCallback).

Parameters
url the URL of the resource to load
extraHeaders the additional headers to be used in the HTTP request for this URL, specified as a map from name to value. Note that if this map contains any of the headers that are set by default by this WebView, such as those controlling caching, accept types or the User-Agent, their values may be overridden by this WebView's defaults.

public void onPause ()

Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. To pause JavaScript globally, use pauseTimers(). To resume WebView, call onResume().

public void onResume ()

Resumes a WebView after a previous call to onPause().

public boolean pageDown (boolean bottom)

Scrolls the contents of this WebView down by half the page size.

Parameters
bottom true to jump to bottom of page
Returns
  • true if the page was scrolled

public boolean pageUp (boolean top)

Scrolls the contents of this WebView up by half the view size.

Parameters
top true to jump to the top of the page
Returns
  • true if the page was scrolled

public void pauseTimers ()

Pauses all layout, parsing, and JavaScript timers for all WebViews. This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused.

public void postUrl (String url, byte[] postData)

Loads the URL with postData using "POST" method into this WebView. If url is not a network URL, it will be loaded with loadUrl(String) instead, ignoring the postData param.

Parameters
url the URL of the resource to load
postData the data will be passed to "POST" request, which must be be "application/x-www-form-urlencoded" encoded.

public void reload ()

Reloads the current URL.

public void removeJavascriptInterface (String interfaceName)

Removes a previously injected Java object from this WebView. Note that the removal will not be reflected in JavaScript until the page is next (re)loaded. See addJavascriptInterface(Object, String).

Parameters
interfaceName the name used to expose the object in JavaScript

public void removeView (View view)

Remove view from webview

Parameters
view view to remove

public void requestFocusNodeHref (Message hrefMsg)

Requests the anchor or image element URL at the last tapped point. If hrefMsg is null, this method returns immediately and does not dispatch hrefMsg to its target. If the tapped point hits an image, an anchor, or an image in an anchor, the message associates strings in named keys in its data. The value paired with the key may be an empty string.

Parameters
hrefMsg the message to be dispatched with the result of the request. The message data contains three keys. "url" returns the anchor's href attribute. "title" returns the anchor's text. "src" returns the image's src attribute.

public void requestImageRef (Message msg)

Requests the URL of the image last touched by the user. msg will be sent to its target with a String representing the URL as its object.

Parameters
msg the message to be dispatched with the result of the request as the data member with "url" as key. The result can be null.

public WebBackForwardList restoreState (Bundle inState)

Restores the state of this WebView from the given Bundle. This method is intended for use in android.app.Activity#onRestoreInstanceState and should be called to restore the state of this WebView. If it is called after this WebView has had a chance to build state (load pages, create a back/forward list, etc.) there may be undesirable side-effects. Please note that this method no longer restores the display data for this WebView.

Parameters
inState the incoming Bundle of state
Returns
  • the restored back/forward list or null if restoreState failed

public void resumeTimers ()

Resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers.

public WebBackForwardList saveState (Bundle outState)

Saves the state of this WebView used in android.app.Activity#onSaveInstanceState. Please note that this method no longer stores the display data for this WebView. The previous behavior could potentially leak files if restoreState(Bundle) was never called.

Parameters
outState the Bundle to store this WebView's state
Returns
  • the same copy of the back/forward list used to save the state, null if the method fails.

public void saveWebArchive (String filename)

Saves the current view as a web archive.

Parameters
filename the filename where the archive should be placed

public void saveWebArchive (String basename, boolean autoname, ValueCallback<String> callback)

Saves the current view as a web archive.

Parameters
basename the filename where the archive should be placed
autoname if false, takes basename to be a file. If true, basename is assumed to be a directory in which a filename will be chosen according to the URL of the current page.
callback called after the web archive has been saved. The parameter for onReceiveValue will either be the filename under which the file was saved, or null if saving the file failed.

public void setBackgroundColor (int color)

Sets the background color for this WebView.

Parameters
color the color of the background

public static void setDataDirectorySuffix (String suffix)

Define the directory used to store WebView data for the current process. The provided suffix will be used when constructing data and cache directory paths.

Parameters
suffix The directory name suffix to be used for the current process. Must not contain a path separator.

public void setDownloadListener (DownloadListener listener)

Registers the interface to be used when content can not be handled by the rendering engine, and should be downloaded instead. This will replace the current handler.

Parameters
listener an implementation of DownloadListener

public void setFindListener (IX5WebViewBase.FindListener listener)

Registers the listener to be notified as find-on-page operations progress. This will replace the current listener.

Parameters
listener an implementation of IX5WebViewBase.FindListener

public void setHttpAuthUsernamePassword (String host, String realm, String username, String password)

Stores HTTP authentication credentials for a given host and realm to the WebViewDatabase instance.

Parameters
host the host to which the credentials apply
realm the realm to which the credentials apply
username the username
password the password

public void setInitialScale (int scaleInPercent)

Sets the initial scale for this WebView. 0 means default. The behavior for the default scale depends on the state of getUseWideViewPort() and getLoadWithOverviewMode(). If the content fits into the WebView control by width, then the zoom is set to 100%. For wide content, the behavior depends on the state of getLoadWithOverviewMode(). If its value is true, the content will be zoomed out to be fit by width into the WebView control, otherwise not. If initial scale is greater than 0, WebView starts with this value as initial scale. Please note that unlike the scale properties in the viewport meta tag, this method doesn't take the screen density into account.

Parameters
scaleInPercent the initial scale in percent

public void setNetworkAvailable (boolean networkUp)

Informs WebView of the network state. This is used to set the JavaScript property window.navigator.isOnline and generates the online/offline event as specified in HTML5, sec. 5.7.7

Parameters
networkUp a boolean indicating if network is available

public void setOnLongClickListener (View.OnLongClickListener l)

Register a callback to be invoked when this WebView is clicked and held. If this view is not long clickable, it becomes long clickable.

Parameters
l The callback that will run

public void setOnTouchListener (View.OnTouchListener onTouchListener)

Register a callback to be invoked when a touch event is sent to this view.

Parameters
onTouchListener the touch listener to attach to this view

public void setVisibility (int visibility)

Set the visibility state of this WebView.

Parameters
visibility One of VISIBLE, INVISIBLE, or GONE.

public void setWebChromeClient (WebChromeClient client)

Sets the chrome handler. This is an implementation of WebChromeClient for use in handling JavaScript dialogs, favicons, titles, and the progress. This will replace the current handler.

Parameters
client an implementation of WebChromeClient

public void setWebChromeClientExtension (IX5WebChromeClientExtension client)

Set IX5WebChromeClientExtension for webview, x5 will call the relevant interface in some scene,

Parameters
client IX5WebChromeClientExtension

public static void setWebContentsDebuggingEnabled (boolean enabled)

Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application. This flag can be enabled in order to facilitate debugging of web layouts and JavaScript code running inside WebViews. Please refer to WebView documentation for the debugging guide. The default is false.

Parameters
enabled whether to enable web contents debugging

public void setWebViewCallbackClient (WebViewCallbackClient client)

Set WebViewCallbackClient for webview, Special callback for app event processing

Parameters
client client

public void setWebViewClient (WebViewClient client)

Sets the WebViewClient that will receive various notifications and requests. This will replace the current handler.

Parameters
client an implementation of WebViewClient

public void setWebViewClientExtension (IX5WebViewClientExtension client)

Set IX5WebViewClientExtension for webview

Parameters
client client

public void stopLoading ()

Stops the current load.

public boolean zoomIn ()

Performs zoom in in this WebView.

Returns
  • true if zoom in succeeds, false if no zoom changes

public boolean zoomOut ()

Performs zoom out in this WebView.

Returns
  • true if zoom out succeeds, false if no zoom changes

Protected Methods

protected void onDetachedFromWindow ()

protected void onSizeChanged (int w, int h, int oldw, int oldh)

protected void onVisibilityChanged (View changedView, int visibility)

called when visibility changed

Parameters
visibility The new visibility of changedView: VISIBLE(0), INVISIBLE(4) or GONE(8).