How to load youtube website in Android WebView?
I have a very simple WebView implementation, it works well in almost all websites, but when it comes to youtube, I can load the home page, video page, but when I click play button (on page m.youtube.com/index?desktop_uri=%2F&gl=US#/watch?v=xxxxxx), the vi开发者_开发技巧deo flash but does not play. My android version is 2.3.
first update your flash player ....
second check for permission like you have given for internet or not in androidMenifest file
third
i dont know why but webviewclient class causes the problem , we can run it in default browser remove the webviewclient class and simly load the url of youtube you will be able to run it on 2.2,2.3
w=(WebView)findViewById(R.id.webview);
w.getSettings().setJavaScriptEnabled(true);
w.getSettings().setPluginsEnabled(true);
w.loadUrl("http://www.youtube.com");
for 2.1 just add this, use intent and through parse method open it through default installed youtube application
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/v/%s")))); }
精彩评论