Holiday learning record 18 (Android realize tone)

android tone is actually very simple and did not need the bells and whistles, like music players

First we establish raw folder under the res folder, then go into an audio file (note that raw and layout is the same level do not build the wrong position)

Then only need to add the following four lines of code on it

      MediaPlayer mediaPlayer = null;
        mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.music);
        mediaPlayer.setVolume(0.05f, 0.05f);
        mediaPlayer.start();

 

Guess you like

Origin www.cnblogs.com/837634902why/p/12617176.html