Skip to content
Advertisement

Why Google Vignette Ads not showing in Android WebView (Java)?

In the app there is a webview which views a webpage which has a vignette ad, but the ad is not shown in webview, its shown in other mediums, what may be the cause ? is there any policy that’s preventing it from appearing ?

Advertisement

Answer

Found that adding these lines enabled Vignette in webpage

    webView.getSettings().setJavaScriptEnabled(true);
    //Zoom
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);
    //Cache and storage
    webView.getSettings().setAppCacheEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    //optional settings
    webView.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath());
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setAppCacheEnabled(true);
    //Others
    webView.setFocusable(true);
    webView.setFocusableInTouchMode(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);//the best for games
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement