【问题标题】:Youtube intent filter & schemeYoutube 意图过滤器和方案
【发布时间】:2013-06-22 22:41:08
【问题描述】:

我正在尝试接收来自 Youtube 应用的意图。 IE。当我按共享时,它应该在准备接受此意图的应用程序上列出我的应用程序。但这些都不起作用

<intent-filter>
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="image/*" />
  <data android:mimeType="video/*" />
  <data
    android:host="*"
    android:scheme="youtube" />
  <data
    android:host="*"
    android:scheme="vnd.youtube" />
</intent-filter>

或带有动作视图

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="image/*" />
  <data android:mimeType="video/*" />
  <data
    android:host="*"
    android:scheme="youtube" />
  <data
    android:host="*"
    android:scheme="vnd.youtube" />
</intent-filter>

知道如何在发送后也获得意图吗? 谢谢

【问题讨论】:

  • 同样的情况,你找到解决办法了吗?
  • 你找到解决办法了吗?

标签: android youtube


【解决方案1】:

YouTube 应用会发送 text/plain 数据,因此请将您的活动注册为该 MIME 类型的接收者:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

【讨论】:

    【解决方案2】:
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:host="www.youtube.com"
                    android:mimeType="text/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:host="m.youtube.com"
                    android:mimeType="text/plain" />
            </intent-filter>
    

    【讨论】:

      【解决方案3】:

      你似乎很困惑。您使用的意图似乎是像 YouTube 应用程序本身这样的应用程序用来打开视频的意图。你想要的是分享一个 YouTube 视频,即一个链接,所以正如其他答案所提到的,你应该声明一个 text/plainintent-filter。

      但是,此意图过滤器将捕获所有 text/plain 内容,而不仅仅是来自 YouTube 的内容。见:Intent-filter: How to accept only "text/plain" intents containing the word "spaghetti"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-12
        • 2015-05-01
        • 2013-05-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多