English | Site Directory

Android - An Open Handset Alliance Project

android.webkit
public class

android.webkit.WebView

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.AbsoluteLayout
android.webkit.WebView

The Android SDK provides a custom scheme to load assets from the application's .apk file in WebView. The prefix "file:///android_asset/" will cause WebView to load content from the current application's assets folder. For example, a myimage.gif file in the /assets folder can be used in the html image tag as:

<img src="file:///android_asset/myimage.gif">

Also see ViewGroup.LayoutParams for layout attributes.

Summary

XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

          WebView(Context context)
          WebView(Context context, AttributeSet attrs, Map inflateParams)
Construct a new WebView with layout parameters.
          WebView(Context context, AttributeSet attrs, Map inflateParams, int defStyle)

Public Methods

        void  addJavascriptInterface(Object obj, String interfaceName)
Use this function to bind a Java object to Javascript so that the methods can be accessed from Javascript.
        boolean  canGoBack()
Return true if this WebView has a back history item.
        boolean  canGoBackOrForward(int steps)
Return true if the page can go back or forward the given number of steps.
        boolean  canGoForward()
Return true if this WebView has a forward history item.
        void  clearAllUsernamesAndPasswords()
Clear all the username and password pairs stored in the internal database.
        void  clearCache()
Clear the resource cache.
        void  clearFormData()
Make sure that clearing the form data removes the adapter from the currently focused textfield if there is one.
        void  clearHistory()
Tell the WebView to clear its internal back/forward list.
        void  clearHttpAuthUsernamePassword()
Clear the HTTP authorization data stored in response to HTTP authentication requests.
        void  clearSslPreferences()
Clear the SSL preferences table stored in response to proceeding with SSL certificate errors.
        void  computeScroll()
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary.
        WebBackForwardList  copyBackForwardList()
Return the WebBackForwardList for this WebView.
        Bitmap  createSnapshot(int width, int height, float scale)
Create a snapshot of the page in the given width and height with the given scale.
        void  destroy()
Destroy the internal state of the WebView.
      static  void  disablePlatformNotifications()
If platform notifications are enabled, this should be called from onPause() or onStop().
        boolean  dispatchTouchEvent(MotionEvent ev)
Pass the touch screen motion event down to the target view, or this view if it is the target.
      static  void  enablePlatformNotifications()
Enables platform notifications of data state and proxy changes.
        void  findFirst(String find, Message response)
Find and highlight the first occurance of find, beginning with the start of the page.
        void  findNext(String find, Message response)
Find and highlight the next occurance of the String find, beginning with the current selection.
        void  findPrevious(String find, Message response)
Find and highlight the previous occurance of the String find, beginning with the current selection.
        Bitmap  getFavicon()
Get the favicon for the current page.
        String  getFocusNodePath()
Return a proper String depending on the type of the focus node.
        String[]  getHttpAuthUsernamePassword(String host, String realm)
Retrieve the HTTP authentication username and password for a given host & realm pair
        int  getProgress()
Get the progress for the current page.
        WebSettings  getSettings()
Return the WebSettings object used to control the settings for this WebView.
        String  getTitle()
Get the title for the current page.
        String  getUrl()
Get the url for the current page.
        int  getZoomWidth()
Return the current zoom width of the WebView.
        void  goBack()
Go back in the history of this WebView.
        void  goBackOrForward(int steps)
Go to the history item that is the number of steps away from the current item.
        void  goForward()
Go forward in the history of this WebView.
        boolean  hasFormData()
Returns true if there is any form data stored in this WebView's internal database.
        boolean  hasHttpAuthUsernamePassword()
        boolean  hasUsernameAndPassword()
Returns true if there is a username and password pair stored in the WebView's internal database.
        void  invokeZoomPicker()
Invoke the graphical zoom picker widget for this WebView.
        void  loadData(String data, String mimeType, String encoding)
Load the given data into the WebView.
        void  loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String failUrl)
Load the given data into the WebView, use the provided URL as the base URL for the content.
        void  loadUrl(String url)
Load the given url.
        boolean  onKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_NEWLINE is released, if the view is enabled and clickable.
        boolean  onKeyUp(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_NEWLINE is released.
        void  pauseTimers()
Pause all layout, parsing, and javascript timers.
        boolean  performLongClick()
Call this view's OnLongClickListener, if it is defined.
        void  reload()
Reload the current url.
        boolean  requestChildRectangleOnScreen(View child, Rect rect, boolean immediate)
Called when a child of this group wants a particular rectangle to be positioned onto the screen.
        boolean  requestFocus(int direction, Rect previouslyFocusedRect)
Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. This implements the focus type logic (getFocusType()), respecting this group's preference for NORMAL_FOCUS or WEAK_FOCUS.
        void  requestFocusNodeHref(Message hrefMsg)
Request the href of an anchor element due to getFocusNodePath returning "href." If hrefMsg is null, this method returns immediately and does not dispatch hrefMsg to its target.
        WebBackForwardList  restoreState(Bundle inState)
Restore the state of this WebView from the given map used in Activity.onThaw.
        void  resumeTimers()
Resume all layout, parsing, and javascript timers.
        void  savePassword(String host, String username, String password)
Save the username and password for a particular host in the WebView's internal database.
        WebBackForwardList  saveState(Bundle outState)
Save the state of this WebView used in Activity.onFreeze.
        void  setDownloadListener(DownloadListener listener)
Register the interface to be used when content can not be handled by the rendering engine, and should be downloaded instead.
        void  setHttpAuthUsernamePassword(String host, String realm, String username, String password)
Set the HTTP authentication credentials for a given host and realm.
        void  setLayoutParams(LayoutParams params)
Set the layout parameters associated with this view.
        void  setWebBackForwardListClient(WebBackForwardListClient client)
Set the WebBackForwardListClient.
        void  setWebChromeClient(WebChromeClient client)
Set the chrome handler.
        void  setWebViewClient(WebViewClient client)
Set the WebViewClient that will receive various notifications and requests.
        void  setZoomWidth(int width)
Set a new zoom width for the WebView.
        void  stopLoading()
Stop the current load.

Protected Methods

        int  computeHorizontalScrollRange()

Compute the horizontal range that the horizontal scrollbar represents.

        int  computeVerticalScrollRange()

Compute the vertical range that the vertical scrollbar represents.

        void  finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
        void  onDraw(Canvas canvas)
Implement this to do your drawing.
        void  onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
        void  onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

        void  onScrollChanged(int l, int t, int oldl, int oldt)
This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents).
        void  onSizeChanged(int w, int h, int ow, int oh)
This is called during layout when the size of this view has changed.
Methods inherited from class android.widget.AbsoluteLayout
Methods inherited from class android.view.ViewGroup