Code example for WebView

Methods: setWebChromeClientsetWebViewClient, setDownloadListener, setOnCreateContextMenuListener

0
    /* 
     * Put the tab in the background using all the empty/background clients. 
     */ 
    private void putTabInBackground(Tab t) {
        WebView mainView = t.mMainView;
        // Set an empty callback so that default actions are not triggered. 
        mainView.setWebViewClient(mEmptyClient);
        mainView.setWebChromeClient(mBackgroundChromeClient);
        mainView.setOnCreateContextMenuListener(null);
        // Leave the DownloadManager attached so that downloads can start in 
        // a non-active window. This can happen when going to a site that does 
        // a redirect after a period of time. The user could have switched to 
        // another tab while waiting for the download to start. 
        mainView.setDownloadListener(mActivity);
        WebView subView = t.mSubView;
        if (subView != null) {
            // Set an empty callback so that default actions are not triggered. 
            subView.setWebViewClient(mEmptyClient);
            subView.setWebChromeClient(mBackgroundChromeClient);
            subView.setOnCreateContextMenuListener(null);
            subView.setDownloadListener(mActivity);
        } 
    } 
 
    /*