1

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.

4

3 回答 3

5

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>
于 2013-02-04T07:28:29.910 回答
1

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/>
于 2017-10-30T05:22:26.817 回答
0

you can do it by setting this fun to edittext change , it works fine for me :)

edittext change:

   binding.etSearch.addTextChangedListener(object : TextWatcher {
        override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {

        }

        override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
            onQueryTextChange(s.toString())
        }

        override fun afterTextChanged(s: Editable?) {

        }
    })

search filter function :

   fun onQueryTextChange(newText: String){
    val folder = intent.getSerializableExtra("folder") as Folder
    val userInput = newText.toLowerCase()
    val myFiles = ArrayList<ModelAudio>()
    for (song in folder.musicList) {
        if (song.audioTitle!!.toLowerCase().contains(userInput)){
            myFiles.add(song)
        }
    }
    adapter.differ.submitList(myFiles)
}
于 2021-04-26T06:32:13.910 回答