📌  相关文章
📜  如何以编程方式从 android 中选择音频 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:35.153000             🧑  作者: Mango

代码示例1
You can put below codes in your project when you want to select audio.

Intent intent_upload = new Intent();
intent_upload.setType("audio/*");
intent_upload.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent_upload,1);
And override onActivityResult in the same Activity, as below

@Override 
protected void onActivityResult(int requestCode,int resultCode,Intent data){

  if(requestCode == 1){

    if(resultCode == RESULT_OK){

        //the selected audio.
        Uri uri = data.getData(); 
    }
  }
  super.onActivityResult(requestCode, resultCode, data);
}