Limit Javascript support in WebView - Android User Interface

Android examples for User Interface:WebView Javascript

Description

Limit Javascript support in WebView

Demo Code


//package com.java2s;

import android.webkit.WebSettings;
import android.webkit.WebView;

public class Main {

    public static void limitWebView(WebView webView, boolean disableJS,
            boolean disablePlugin, boolean disableFileAccess,
            boolean noCache) {
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(disableJS);
        //      settings.setPluginsEnabled(disablePlugin);
        settings.setAllowFileAccess(disableFileAccess);
        settings.setAppCacheEnabled(noCache);
    }/*  w  ww . j  a v  a  2 s. co m*/
}

Related Tutorials