Youtube意图过滤器和方案

3

我正在尝试从Youtube应用程序接收意图。也就是说,当我按分享时,它应该在准备接受此意图的应用程序列表中列出我的应用程序。但是这些都无法正常工作。

<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>

或者使用 VIEW 操作。
<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>

有没有想法在发送后如何获取意图? 谢谢。

同样的情况,你找到解决方案了吗? - cprcrack
你找到解决方案了吗? - Dan
3个回答

0
        <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>

0

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>

0

您似乎有些困惑。您使用的意图似乎是像YouTube应用程序本身一样用于打开视频的意图。您想要分享一个YouTube视频,即一个链接,因此,正如其他答案所提到的那样,您应该声明一个text/plain意图过滤器。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接