Twitter Video Blockquote not rendering properly in Webview

android

#1

I’m trying to show all the twitter blockquotes in a webview. The tweets are rendering properly. But, Twitter videos are not showing properly. Sometimes, it shows with the text along with a huge space and sometimes just the space. Below is my code used to load twitter blockquotes in a webview:

public static void showTweetsinWebview(String embedUrl, TweetViewContainer tweetContainer, LinearLayout container, BaseFragment.OnInlinelinkClickListner listener, Activity activity, Fragment fragment) {
        if (activity != null && container != null && fragment != null && embedUrl != null) {
            if (tweetContainer == null) {
                tweetContainer = new TweetViewContainer(activity);
                container.addView(tweetContainer);
            }
            VideoEnabledWebview vWebview = initWebview(activity, fragment);
            ProgressBar progressBar = createDynamicLoader(activity, container);


            if (embedUrl != null) {
                String html = "<!DOCTYPE html><html> <head> \n" +
                        "\n" +
                        "<script async src =\"https://platform.twitter.com/widgets.js\" \n" +
                        "charset=\"utf-8\"></script></head>" +
                        " <body>" + embedUrl + "</body> </html> ";
                vWebview.setWebUrl(html);
                initWebviewListeners(vWebview, listener, progressBar, activity);
//                vWebview.loadDataWithBaseURL("https://twitter.com", html, "text/html", "utf-8", null);
                vWebview.loadData(html, "text/html", "UTF-8");
                tweetContainer.setBackgroundResource(0);
                tweetContainer.addView(vWebview);
                tweetContainer.setTag(embedUrl);

            }
        }
    }

Also, I tried testing the html content in W3Schools and even in this site, it is rendering properly. When the same code displays tweets properly, why videos aren’t rendering properly.


#2

Is your embedUrl of the basic format:

<blockquote class="twitter-video"><a href="https://twitter.com/Twitter/status/560070183650213889"></a></blockquote>

What CSP or sandbox values might be applied to the embed?


#3

@niall,
The blockquote has twitter-video. Plese find the below blockquote:

Happy Birthday @msdhoni! The more the candles the more the light that will shine in your life wish you all the best pic.twitter.com/uECxolq7ZX

- Suresh Raina (@ImRaina) July 7, 2016

It renders properly in web page. I tired it in W3 schools page. But it doens’t render properly in android webview.


#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.