Twitter video not loading android webview

家住魔仙堡 提交于 2020-01-11 13:00:50

问题


When playing twitter video in android web view it shows the message 'by playing this video you agree to the Twitter use of cookies' and video is not played after that.

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
    CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
} else
    CookieManager.getInstance().setAcceptCookie(true);
}
webView.getSettings().setJavaScriptEnabled(true);
webView.setBackgroundColor(Color.parseColor("#ffffff"));
webView.loadDataWithBaseURL("file:///android_asset/", htmlTemplate, "text/html", "UTF-8", "");

回答1:


JavaScript is disabled in a WebView by default.

WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

UPDATED:

Use TweetView for Native Videos Launching native video support for Twitter Kit




回答2:


Call loadDataWithBaseURL instead of loadData, like this:

loadDataWithBaseURL("https://mywebsite.com", mContent, "text/html", "UTF-8", null);



来源:https://stackoverflow.com/questions/49978021/twitter-video-not-loading-android-webview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!