单击.mp3链接时打开我的Android应用程序

时间:2014-09-27 14:52:39

标签: java android intentfilter

我尝试创建一个在浏览器中单击.mp3链接时打开的活动。

这是我的意图过滤器:

<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="file" />
            <data android:scheme="http" />
            <data android:host="*" />
            <data android:mimeType="application/mp3" />
        </intent-filter>

没有任何作用。

2 个答案:

答案 0 :(得分:1)

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

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

            <data
                android:host="*"
                android:pathPattern=".*.mp3"
                android:scheme="http" />
        </intent-filter>

它没有用,因为我把:<action android:name="android.intent.action.SEND" /> 在intent-filter里面。现在我在我的活动中只有多个intent-filters。

答案 1 :(得分:0)

作为替代方案,您也可以尝试:

<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="content" />
    <data android:scheme="file" />
    <data android:pathPattern=".*mp3" />
    <data android:mimeType="audio/*" />
</intent-filter>
相关问题