1

I think its because images are large, but, if anybody has different opinion, please, share.

So, im receiving notification like HTML, and want to present it in web view. Now, when i present notifications with smaller pictures, everything works fine. When I present notifications with bigger picture(s), text is there, but image has icon like it crashed. What can I do to make this work?

        mWebView = (WebView) root.findViewById(R.id.party_web_view);
        mWebView.getSettings().setDomStorageEnabled(true);

        mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
        mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
        mWebView.loadData( mContent, "text/html", "UTF-8");
Android Surya
  • 544
  • 3
  • 17
Miljan Vulovic
  • 1,586
  • 3
  • 20
  • 48

1 Answers1

1

So, what I did was this:

mWebView = (WebView) root.findViewById(R.id.party_web_view);
        mWebView.getSettings().setDomStorageEnabled(true);

        mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
        mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
        mWebView.clearCache(true);
        mWebView.getSettings().setLoadsImagesAutomatically(true);
        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.setWebViewClient(new WebViewClient() {
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                handler.proceed();
            }
        });
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

and then, when loading some content,

 mWebView.post(new Runnable() {
            @Override
            public void run() {
                mWebView.loadData(mContent, "text/html", "UTF-8");
            }
        });

Hope it helps..

Vulovic Vukasin
  • 1,540
  • 2
  • 21
  • 30