Reputation: 731
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.
Upvotes: 1
Views: 2998
Reputation: 183
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)
}
Upvotes: 0
Reputation: 143
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/>
Upvotes: 1
Reputation: 7023
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>
Upvotes: 5