【问题标题】:Listening to YouTube links using intent filter使用意图过滤器收听 YouTube 链接
【发布时间】:2015-05-01 05:56:49
【问题描述】:

我正在尝试让我的应用像 YouTube 应用一样收听 YouTube 链接。我有一个带有以下意图过滤器的活动:

<activity android:name=".YoutubeLinkActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="youtube.com"/>    
            </intent-filter>
</activity>  

但是,打开的应用是默认的 YouTube 应用,而不是我的。我也为其他host 尝试了相同的意图过滤器。在这种情况下,浏览器只是转到下一页而不是启动我的应用程序。

这里需要改变什么?

【问题讨论】:

  • 使用 App Browser app 检查 YouTube 应用的清单,看看您的不同之处。

标签: android android-intent youtube intentfilter


【解决方案1】:

我遇到了类似的问题,有趣的是它在 Android 2.3.7 中运行良好。

为了让它在 JB 及更高版本上运行,我将android:pathPrefix="" 添加到我的&lt;data&gt; 标签中。所以我的&lt;intent-filter&gt; 看起来像:

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>

    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>

    <data
        android:host="android.app.myWeb.pk"
        android:pathPrefix=""
        android:scheme="http"/>
    <data
        android:host="android.app.myWeb.pk"
        android:pathPrefix=""
        android:scheme="https"/>
</intent-filter>

【讨论】:

  • @LittleChild 如果此答案或任何答案解决了您的问题,请单击复选标记考虑accepting it。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-25
  • 2016-11-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多