Example usage for android.webkit WebView getSettings

List of usage examples for android.webkit WebView getSettings

Introduction

In this page you can find the example usage for android.webkit WebView getSettings.

Prototype

public WebSettings getSettings() 

Source Link

Document

Gets the WebSettings object used to control the settings for this WebView.

Usage

From source file:com.llkj.cm.restfull.network.NetworkConnection.java

/**
 * By default the user agent is empty. If you want to use the standard Android user agent, call this method before using the
 * <code>retrieveResponseFromService</code> methods
 * /* w w  w.ja  va  2s  . co  m*/
 * @param context The context
 */
public static void generateDefaultUserAgent(final Context context) {
    if (sDefaultUserAgent != null) {
        return;
    }

    try {
        Constructor<WebSettings> constructor = WebSettings.class.getDeclaredConstructor(Context.class,
                WebView.class);
        constructor.setAccessible(true);
        try {
            WebSettings settings = constructor.newInstance(context, null);
            sDefaultUserAgent = settings.getUserAgentString();
        } finally {
            constructor.setAccessible(false);
        }
    } catch (Exception e) {
        if (Thread.currentThread().getName().equalsIgnoreCase("main")) {
            WebView webview = new WebView(context);
            sDefaultUserAgent = webview.getSettings().getUserAgentString();
        } else {
            Thread thread = new Thread() {
                @Override
                public void run() {
                    Looper.prepare();
                    WebView webview = new WebView(context);
                    sDefaultUserAgent = webview.getSettings().getUserAgentString();
                    Looper.loop();
                }
            };
            thread.start();
        }
    }
}

From source file:org.microg.gms.auth.login.LoginActivity.java

private static WebView createWebView(Context context) {
    WebView webView = new WebView(context);
    if (SDK_INT < LOLLIPOP) {
        webView.setVisibility(VISIBLE);/*  w w w  .java  2  s.c  o  m*/
    } else {
        webView.setVisibility(INVISIBLE);
    }
    webView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setBackgroundColor(Color.TRANSPARENT);
    prepareWebViewSettings(webView.getSettings());
    return webView;
}

From source file:com.just.agentweb.AgentWebUtils.java

static void clearWebViewAllCache(Context context, WebView webView) {

    try {/*from w  w  w .  ja  v a 2  s  .c  o m*/

        AgentWebConfig.removeAllCookies(null);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        context.deleteDatabase("webviewCache.db");
        context.deleteDatabase("webview.db");
        webView.clearCache(true);
        webView.clearHistory();
        webView.clearFormData();
        clearCacheFolder(new File(AgentWebConfig.getCachePath(context)), 0);

    } catch (Exception ignore) {
        //ignore.printStackTrace();
        if (AgentWebConfig.DEBUG) {
            ignore.printStackTrace();
        }
    }
}

From source file:com.github.pennyfive.cinemafinlando.ui.fragment.OpenSourceLicensesDialogFragment.java

@NonNull
@Override//from w  w  w.  ja v a  2 s .co  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new Builder(getActivity());
    builder.setTitle(R.string.about_open_source_licenses_text);
    WebView webView = new WebView(getActivity());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);
    webView.getSettings().setTextZoom(60);
    webView.loadUrl("file:///android_asset/licenses.html");
    builder.setView(webView);
    return builder.create();
}

From source file:io.github.waka.sevenhack.activities.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_license);

    initToolbar();//from  w w  w.jav  a2s .  c  o  m

    WebView webView = binding.webView;
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.loadUrl(LICENSES_HTML_PATH);
}

From source file:com.chatwing.whitelabel.fragments.ProfileInfoFragment.java

private void configWebView(WebView webView) {
    WebSettings webSettings = webView.getSettings();
    webSettings.setAppCacheEnabled(false);
    webSettings.setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
}

From source file:com.example.myapplicationtranslator.ui.OpenSourceLicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_source_licenses);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    WebView webView = (WebView) findViewById(R.id.web_view);

    webView.getSettings().setBuiltInZoomControls(false);
    webView.loadUrl("file:///android_asset/open_source_licenses.html");
}

From source file:org.namelessrom.devicecontrol.about.LicenseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_webview, container, false);

    final WebView wv = (WebView) view.findViewById(R.id.dialog_help_webview);
    wv.getSettings().setTextZoom(90);

    final String url = Application.get().isDarkTheme() ? "file:///android_asset/license_dark.html"
            : "file:///android_asset/license.html";
    wv.loadUrl(url);/* w w w .  ja  v a  2 s  . c  o m*/

    return view;
}

From source file:org.namelessrom.devicecontrol.about.PrivacyFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_webview, container, false);

    final WebView wv = (WebView) view.findViewById(R.id.dialog_help_webview);
    wv.getSettings().setTextZoom(90);

    final String url = Application.get().isDarkTheme() ? "file:///android_asset/privacy_dark.html"
            : "file:///android_asset/privacy.html";
    wv.loadUrl(url);/*from  ww w  . j  a v a 2  s .c  om*/

    return view;
}

From source file:org.namelessrom.devicecontrol.modules.about.LicenseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_webview, container, false);

    final WebView wv = (WebView) view.findViewById(R.id.dialog_help_webview);
    wv.getSettings().setTextZoom(90);

    final String url = AppResources.get().isDarkTheme() ? "file:///android_asset/license_dark.html"
            : "file:///android_asset/license.html";
    wv.loadUrl(url);/* w ww . ja v a  2s. com*/

    return view;
}