简体   繁体   中英

Is it possible to filter or remove results shown when using PICK_ACTION and MediaStore.Audio.Media.EXTERNAL_CONTENT_URI?

I'm using the following method to launch an Activity that allows me to pick a song from the MediaStore library and return a uri for it to the launching activity.

public void selectMedia()
{
        Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(i, REQUEST_MEDIA);
}

I've been searching and searching for a way to filter the list that is shown so that it doesn't include alarms and ringtones. Since I couldn't find a solution for it I started looking for a way to specify a "root dir" in which the media files should be in.

All I find is much more complex examples on how to query the MediaStore as a ContentProvider for specific results and then display the results in a custom ListView.

I'm curious to find an answer to if this is the only way to achieve what I'm trying to do or if it is possible to solve by passing some extra information with the intent.

No, it does not seem possible at this time. I ended up writing my own activity for selection and it queries the media store as appropriate.

The solution can be found here:

I have written my own solution for this now, anyone who needs it can find it here

https://stackoverflow.com/a/12710411/1068167

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM