/ Music Player

An Android music picker library for picking alarm

An Android music picker library for picking alarm


An Android music picker library for picking alarm, notification or ringtones sound using an Activity or a dialog.


Activity Dialog Dark

Gradle Dependency

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }

Step 2. Add the dependency

The Newest Version

dependencies {
    implementation "com.github.DeweyReed:UltimateMusicPicker:${version}"


    // Picker activity action bar title or dialog title

    // Add a extra default item
    // Add default and change the default item name("Default" is used otherwise)
    .defaultTitleAndUri("My default name", uri)

    // Use this to remove the "Silent" item

    // Select this uri

    // Add some other music items(from R.raw or app's asset)
    .additional("Myself Music", uri)
    .additional("Another Music", uri)

    // Music preview stream type

    // Show device ringtones sound
    // Show device notification sound
    // Show device alarm sound
    // Show music files from external storage.
    // Remember to add READ_EXTERNAL_STORAGE permission to your `Manifest.xml`.

    // Show a picker dialog
    // Remember to implement MusicPickerListener for the calling activity or fragment
    // Or show a picker activity. Check below for more.
    //.goWithActivity(this, 0, MusicPickerActivity::class.java)

Things to remember:

  • No permission is needed(RingtoneManager is used internally) unless you use .music() to select music files in the external storage.

    If so, add READ_EXTERNAL_STORAGE permission to your app's Manifest.xml and the library will handle permission request properlly.

  • When use .goWithDialog(supportFragmentManager), the calling class should implement MusicPickerListener to get pick result.

  • When use .goWithActivity(this, 0, MusicPickerActivity::class.java)(the thrid parameter is an Activity implementing MusicPickerListener), add MusicPickerActivity(already defined in the library) in your Manifest.xml.

    Then in the activity's onActivityResult,

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (resultCode == Activity.RESULT_OK) {
            val title = data?.getStringExtra(UltimateMusicPicker.EXTRA_SELECTED_TITLE)
            val uri = data?.getParcelableExtra<Uri>(UltimateMusicPicker.EXTRA_SELECTED_URI)
            if (title != null && uri != null) {
                onMusicPick(uri, title)
            } else {
        } else super.onActivityResult(requestCode, resultCode, data)

Advanced Usage

The picker view is a Fragment so it can be easily used in an Activity and a dialog.

Custom Activity

Simply copy and paste MusicPickerActivity or MusicPickerDialog and create your own. You may notice it's just a wrapper for MusicPickerFragment and it can be used in many places(like in a ViewPager?)

What's more, there are two methods in the UltimateMusicPicker class to help you.

  * Create a setting [Parcelable]. Useful when customize how to start activity
fun buildParcelable(): Parcelable

  * Put a setting [Parcelable] into a [Intent]. Useful when customize how to start activity
fun putSettingIntoIntent(intent: Intent): Intent

Dark Theme

This library supports dark theme with a naive way. It works fine when I use AppCompatDelegate.setDefaultNightMode to toggle night theme. If this is not enough, open a issue or send a PR.

Todo List

  • AndoridX support
  • Use READ_CONTENT to select without permission