【问题标题】:intent to youtube app profile/channel意图 youtube 应用程序配置文件/频道
【发布时间】:2012-02-09 01:52:35
【问题描述】:

我可以通过 youtube 应用轻松地观看视频,但是如何访问个人资料/频道?

    public void YouTube(String id) {
        // Play Youtube Video
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:"+id));
        mContext.startActivity(i);
    }

我..只是不知道从哪里真正开始?是否有要解析的特定 Uri?当然,我已经尝试过在互联网上搜索,但我正在寻找答案。一开始有可能吗?

谢谢大家!

【问题讨论】:

  • 请问您找到解决方案了吗?

标签: java android youtube


【解决方案1】:

通过以下操作,可以直接启动Youtube App显示频道

Intent intent=null;     
try {
        intent =new Intent(Intent.ACTION_VIEW);
        intent.setPackage("com.google.android.youtube");
        intent.setData(Uri.parse(url));
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        startActivity(intent);
    }

并且为了显示频道,请记住以http://www.youtube.com/user/channelName格式提供网址

【讨论】:

  • 这应该被标记为正确答案。
【解决方案2】:

到目前为止,还没有针对直接触发 YouTube 应用程序的频道的特定 URI 方案。 vnd.youtube 方案仅针对播放单个视频的活动定义。因此,您必须为频道页面指定规范的 YouTube URL,并且通常让用户通过应用程序选择器对话框 - 假设设备安装了 YouTube 应用程序,该对话框将显示至少两个条目,第二个用于浏览器。

【讨论】:

    猜你喜欢
    • 2014-06-02
    • 2011-03-15
    • 1970-01-01
    • 2010-10-09
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2013-08-29
    相关资源
    最近更新 更多