我正在尝试在 Android 中加载 YouTube 视频。
我在 xml 中添加了一个 WebView:
<WebView android:id="@+id/VideoView"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
然后我按如下方式加载它:
WebView webview = new WebView(this);
setContentView(R.layout.webview);
String htmlString = "<html> <body> <embed src=\"http://www.youtube.com/watch?v=XS998HaGk9M\"; type=application/x-shockwave-flash width="+640+" height="+385+"> </embed> </body> </html>";
webview.loadData(htmlString, "text/html", "utf-8");
我已将适当的权限添加到 list 中。我收到的只是一个空白的白色屏幕,没有加载任何内容。
有人可以帮我解决这个问题吗?
最佳答案
不是使用webview
,而是开始一个新的Intent
...
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=XS998HaGk9M")));
关于android - Android 中的 YouTube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5162697/