Picking up an audio file android

后端 未结 5 1049
花落未央
花落未央 2021-01-31 19:11

I need to fetch an audio file from SD Card and play it. I think this can be done by getting URI of an audio file. So, to pick an audio file I\'m using following code:

         


        
5条回答
  •  北海茫月
    2021-01-31 19:41

    No need to add type here like audio/*. It will crash to search such type of action. Try this. It worked for me.

    val intent = Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI)
            startActivityForResult(intent, AUDIO_REQUEST_CODE)
    

提交回复
热议问题