I am trying to load a YouTube video in Android.
I have added a WebView in xml:
<WebView android:id="@+id/VideoView"
android:layout_height="fill_parent"
android:layo开发者_如何学Pythonut_width="fill_parent" />
I then load it as follows:
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");
I have added the proper permissions to the manifest. All I receive is a blank white screen and nothing loads.
Can someone please help me with this?
Instead of using webview
, just start a new Intent
...
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=XS998HaGk9M")));
精彩评论