如何直接打开YouTube应用通过意向 [英] How to open Youtube App directly via intent

查看:402
本文介绍了如何直接打开YouTube应用通过意向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
   Android版YouTube应用程序播放视频意向

我想知道如何在Android上使用直接打开意图YouTube应用。

I wanted to know how to open Youtube App on Android directly using intent.

我有:

        @Override
        public void onClick(View v) {
        String video_path = "http://www.youtube.com/user/videoslusofona";
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(video_path));
        startActivity(intent);
        }

我不希望是Android问我软件,我想开什么,我想直接点击打开YouTube应用程式。

What i don't want is for Android to ask me what App i want to open, i want to open Youtube App directly on click.

感谢您的时间

推荐答案

您可以试试:

String videoId = "VideoIDGoesHere";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId)); 
intent.putExtra("VIDEO_ID", videoId); 
startActivity(intent);

您可能想看看使用

Intent lVideoIntent = new Intent(null, Uri.parse("ytpl://"+YOUTUBE_PLAYLIST_ID), this, OpenYouTubePlayerActivity.class);
startActivity(lVideoIntent);

维基,你会需要有播放列表ID,但看起来这应该工作。

from the wiki, you'll need to have the playlist id but it seems like this should work.

这篇关于如何直接打开YouTube应用通过意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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