2016-07-30 53 views
0

由於某種原因,我的WebView中的圖像未加載。我無法弄清楚爲什麼即使在這裏嘗試了多種解決方案之後。請幫我解決這個問題。WebView中的圖像未加載

我的應用程序的WebView

enter image description here

我AVD瀏覽器視圖

enter image description here

鏈接到頁面here

WebViewActivity

public class WebViewActivity extends Activity{ 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_webview); 

    final WebView webview = (WebView) findViewById(R.id.webView); 
    //TextView contentView = (TextView) findViewById(R.id.contentView); 


    Intent intent = getIntent(); 
    String address = intent.getStringExtra("URL"); 


    webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 

    webview.setWebViewClient(new WebViewClient() { 
     @Override 
     public void onPageFinished(WebView view, String url) { 

     } 
    }); 


    webview.getSettings().setLoadsImagesAutomatically(true); 
    webview.getSettings().setJavaScriptEnabled(true); 
    webview.getSettings().setDomStorageEnabled(true); 
    webview.loadUrl(address); 


    //textToSpeech.speak("TALK", TextToSpeech.QUEUE_FLUSH, null); 


} 

} 

回答

2

這是一個mixed content問題,因爲您在Webview中使用https協議時調用http協議。

更改混合內容模式setMixedContentMode(int mode)

webview.getSettings(). 
    setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE); 

Android docMIXED_CONTENT_COMPATIBILITY_MODE

使用setMixedContentMode(INT)在此模式下,網頁視圖將嘗試與的方法兼容一個關於混合內容的現代網絡瀏覽器。一些不安全的內容可能被允許通過安全來源加載,而其他類型的內容將被阻止。內容的類型被允許或阻止可能會將發佈更改爲發佈,並且沒有明確定義。此模式旨在供應用程序使用,這些應用程序無法控制呈現的內容,但希望在合理安全的環境中運行。爲了獲得最高的安全性,建議應用程序使用MIXED_CONTENT_NEVER_ALLOW。