Example usage for android.webkit WebSettings getClass

List of usage examples for android.webkit WebSettings getClass

Introduction

In this page you can find the example usage for android.webkit WebSettings getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

/**
 * set page cache/*  w ww  . j  a  v a  2  s.c  o  m*/
 *
 * @param settings
 * @param capacity
 */
public static void setWebViewPageCache(WebSettings settings, int capacity) {
    try {
        Method setPageCache = settings.getClass().getMethod("setPageCacheCapacity", new Class[] { int.class });
        setPageCache.invoke(settings, new Object[] { capacity });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java

private void enableWorkers(WebSettings settings) {
    Class<? extends WebSettings> websettings = settings.getClass();
    Method setWorkersEnabled;/*from  w  ww .  ja va 2  s . c  o m*/
    try {
        setWorkersEnabled = websettings.getDeclaredMethod("setWorkersEnabled", boolean.class);
        setWorkersEnabled.setAccessible(true);
        setWorkersEnabled.invoke(settings, true);
    } catch (Exception e) {
        e.printStackTrace();
        LogUtils.e("enableWorkers failed.");
    }
}

From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java

private void enablePageCache(WebSettings settings, int size) {
    Class<? extends WebSettings> websettings = settings.getClass();
    Field mPageCacheCapacity;/*from  w  w  w  .java 2 s.  c o m*/
    try {
        mPageCacheCapacity = websettings.getDeclaredField("mPageCacheCapacity");
        mPageCacheCapacity.setAccessible(true);
        mPageCacheCapacity.setInt(settings, size);
    } catch (Exception e) {
        LogUtils.e("enablePageCache failed.");
    }
}