How do I make an intent-filter for playing an MP3 file?

你。 提交于 2019-12-18 09:26:44

问题


I have created a music player application in Android. Now, when selecting a music file in the phone's file manager, I want my application to appear as one of the options in the "Complete action using" popup. My idea is to do this using intent filter but I have no idea what action, category, or data I need to supply to it. How do I create an intent filter for this?

I've also seen a related question here: How do I make an intent-filter for streaming an MP3 file? but mine is not streaming, i am just playing music from file.

Thank you in advance.


回答1:


Hope this Intent Filter can help you

<intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="content"/>
        <data android:scheme="file"/>
        <data android:mimeType="audio/*"/>
    </intent-filter>



回答2:


Hope this Intent filter can help you

        <activity android:name="AudioPlayerActivity">
             <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:scheme="content" />
            <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>
      <activity/>


来源:https://stackoverflow.com/questions/14681998/how-do-i-make-an-intent-filter-for-playing-an-mp3-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!