Skip to content Skip to sidebar Skip to footer

Webview Loads Webpage, But Some Contents Get Vanished After Loading (android Studio)

I tried to view http://artikelweb.com in a webview. The web page appears nicely. But, whenever I go to any author link from 'Popular Authors' section, the web page appears, but, af

Solution 1:

In your particular case you must enable the DOM Storage API

webSettings.setDomStorageEnabled(true);

So your code must become:

@SuppressLint("SetJavaScriptEnabled")@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);

    myWebView = (WebView)findViewById(R.id.webView);
    WebSettingswebSettings= myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    myWebView.loadUrl("http://www.artikelweb.com");
    myWebView.setWebViewClient(newWebViewClient());
}

That becouse the javascript that use the website you are accessing needs it in its javascript.

enter image description here

enter image description here

Of course you could take advantage of a third party library, but again you won't know why this exact case works in the third party one and not in the default webview.

The library you are using has this initial settings:

https://raw.githubusercontent.com/delight-im/Android-AdvancedWebView/master/Source/library/src/main/java/im/delight/android/webview/AdvancedWebView.java

finalWebSettingswebSettings= getSettings();
        webSettings.setAllowFileAccess(false);
        setAllowAccessFromFileUrls(webSettings, false);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        if (Build.VERSION.SDK_INT < 18) {
            webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
        }
        webSettings.setDatabaseEnabled(true);
        if (Build.VERSION.SDK_INT < 19) {
            webSettings.setDatabasePath(databaseDir);
        }
        setMixedContentAllowed(webSettings, true);

        setThirdPartyCookiesEnabled(true);

Enabling by default many options that the default webview has disable for security reason.

Solution 2:

Set UserAgent to your Webview settings and try

webSettings.setUserAgentString("Mozilla/5.0 (Linux; <AndroidVersion>; <BuildTagetc.>) AppleWebKit/<WebKitRev> (KHTML, like Gecko) Chrome/<ChromeRev> Mobile Safari/<WebKitRev>");

Post a Comment for "Webview Loads Webpage, But Some Contents Get Vanished After Loading (android Studio)"