[Solved] Is there anybody can help me ? I want to choose some sound ( anywhere in the phone) and send information of this sound to another Activity to play it [closed]


Okay, Here you go

Set the path of file like this-

String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString();

new File(SD_CARD_PATH + "https://stackoverflow.com/" + "your_file_name.mp3");

Code from this SO answer

and use android MediaPlayer to play the song.

public void playSong(String file_path){
    MediaPlayer mediaPlayer = new MediaPlayer();
    try{
        mediaPlayer.setDataSource(file_path);
        mediaPlayer.prepare();
        mediaPlayer.start();
    } catch (Exception e) {
            e.printStackTrace();
    }
}

5

solved Is there anybody can help me ? I want to choose some sound ( anywhere in the phone) and send information of this sound to another Activity to play it [closed]