注册成为音乐播放器 [英] register as music player

查看:161
本文介绍了注册成为音乐播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看到球员的名单我的应用程序(用继续行动......),弹出当我尝试(从文件浏览器或Gmail附件即。)打开一个音频文件。 下面是意图过滤器我试过我的MainActivity:

I'd like to see my app in the list of player ("continue action using...") that pops up when I try to open an audio file (ie. from file browser or gmail attachment). Here are the intent filters I've tried for my MainActivity:

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

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

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

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

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.CATEGORY_APP_MUSIC" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:mimeType="audio/mpeg" />
    </intent-filter>

感谢您的帮助!

thanks for your help !

推荐答案

您总是需要一个&LT;类别&GT; 上的&LT;活性GT; &LT;意向滤光器&gt; ,因为总会有至少一个类别上的意图 startActivity使用()

You always need a <category> on an <activity> <intent-filter>, as there is always at least one category on the Intent used with startActivity().

下面是的AOSP音乐应用<一href="https://github.com/android/platform_packages_apps_music/blob/master/AndroidManifest.xml">uses:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="file"/>
            <data android:mimeType="audio/*"/>
            <data android:mimeType="application/ogg"/>
            <data android:mimeType="application/x-ogg"/>
            <data android:mimeType="application/itunes"/>
        </intent-filter>
        <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" />
            <data android:mimeType="audio/*"/>
            <data android:mimeType="application/ogg"/>
            <data android:mimeType="application/x-ogg"/>
            <data android:mimeType="application/itunes"/>
        </intent-filter>
        <intent-filter
            android:priority="-1">
            <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:mimeType="audio/*"/>
            <data android:mimeType="application/ogg"/>
            <data android:mimeType="application/x-ogg"/>
            <data android:mimeType="application/itunes"/>
        </intent-filter>

这篇关于注册成为音乐播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆