强制视频在Android上的Youtube应用程序打开应用程序、视频、Android、Youtube

由网友(无处安放的蛋蛋)分享简介:我有一个移动网站链接到YouTube视频。在Android上,点击这个链接会打开一个对话框,询问用完整的行动的浏览器或YouTube应用程序的用户。I have a mobile website that links to a youtube video. On Android, clicking on this l...

我有一个移动网站链接到YouTube视频。在Android上,点击这个链接会打开一个对话框,询问用完整的行动的浏览器或YouTube应用程序的用户。

I have a mobile website that links to a youtube video. On Android, clicking on this link brings up a dialog asking the user to "Complete action using" their browser or the Youtube app.

有没有办法绕过这个画面,只是播放视频的YouTube应用程序? (例如拥有YouTube:// URL)

Is there a way to bypass this screen and just play the video in the Youtube app? (For example with a youtube:// URL.)

谢谢!

推荐答案

下面是你如何能做到这一点:

Here's how you can do that:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + id));
startActivity(intent);

ID是在URL中问号后的标识符。例如:youtube.com/watch?v=ID

另一种方法是:

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setData(url);
videoIntent.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(videoIntent);

......

......

阅读全文

相关推荐

最新文章