强制视频在Android上的Youtube应用程序打开 [英] Force video to open in Youtube app on Android

查看:542
本文介绍了强制视频在Android上的Youtube应用程序打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个移动网站链接到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);

......

......

这篇关于强制视频在Android上的Youtube应用程序打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆