I want to embed a youtube video in my Android app. It has a Navigation Drawer, and when this drawer is opened, the video must to keep playing. And I\'d like my app could be capa
For my case Android 4.4.4, adding the Referer header "https://www.youtube.com" in first argument of loadDataWithBaseURL() saved my day!
mWebView = (WebView) getActivity().findViewById(R.id.webView);
if (Build.VERSION.SDK_INT < 8) {
mWebView.getSettings().setPluginsEnabled(true);
} else {
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
}
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.setWebViewClient(new WebViewClient());
mWebView.setBackgroundColor(0x00000000);
mWebView.getSettings().setBuiltInZoomControls(true);
String html = "";
mWebView.loadDataWithBaseURL("https://www.youtube.com", html, "text/html", "UTF-8", null);