Demo entry 5933813

sample

   

Submitted by smpark on Sep 07, 2016 at 10:19
Language: Java. Code size: 1.4 kB.

package laon.webview.example;

import android.content.Context;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebSettings;

import laon.webview.HWebSettings;
import laon.webview.HWebView;

public class ExampleWebView extends HWebView {
    public ExampleWebView(Context context) {
        super(context);
    }

    public static ExampleWebView createWebView(Context context) {
        ExampleWebView wv = new ExampleWebView(context);
        setDefaultSettings(wv.getSettings());
        setExtraSettings(wv.getExtraSettings());
        wv.setWebViewClient(new WebViewClient());
        return wv;
    }

    public static void setDefaultSettings(WebSettings settings) {
        settings.setAllowFileAccess(true);
        settings.setAllowFileAccessFromFileURLs(true);
        settings.setAllowContentAccess(true);
        settings.setJavaScriptEnabled(true);
        settings.setMediaPlaybackRequiresUserGesture(false);
    }

    public static void setExtraSettings(HWebSettings extraSettings) {
        extraSettings.setCeHtmlEnabled(true);
        extraSettings.setBuiltInPluginsEnabled(true);
        extraSettings.setAllowCrossOriginForXmlHttpRequests(true);
        extraSettings.setDefaultFocusRingSuppressed(false);
        extraSettings.setSpatialNavigationOverlayEnabled(false);
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).