Code example for WebView: Displaying web pages

Methods: addJavascriptInterfacegetSettingsloadUrlsetWebChromeClient, setOnLongClickListener, setOnTouchListener

0
            } 
        }); 
 
        WebView webView = (WebView) findViewById(R.id.browser);
        this.webView = webView;
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setPluginsEnabled(true);
        webView.setWebChromeClient(chromeClient);
        webView.addJavascriptInterface(new javaScriptInterface(), "htmlSelectActivity");
        webView.setOnLongClickListener(new View.OnLongClickListener() {
            public boolean onLongClick(View view) {
                return true; 
            } 
        }); 
 
        webView.setOnTouchListener(new View.OnTouchListener() {
            @Override 
            public boolean onTouch(View view, MotionEvent motionEvent) {
 
                if (isSelecting()) { 
                    if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                        Log.e("#############", "reportSelectionCoords");
                        reportSelectionCoords(); 
                    } else if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                        hideClipManager(); 
                    } 
                } 
 
                return gestureScanner.onTouchEvent(motionEvent);
            } 
        }); 
 
        webView.loadUrl("file:///android_asset/html_select_template.html");
 
    } 
    //the user has clicked on the "Toast" button in the clipboard 
    //OSgetSelection() collects the selection string and calls pushSelection(String) 
    private void grabSelection() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE