O'Reilly logo

Android Development Tools for Eclipse by Sanjay Shah, Khirulnizam Abd Rahman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding audio

Before doing this exercise, copy all the sound resources to the assets folder. You may do this by copying all the mp3 files to the assets folder through the File Manager, as shown in the following screenshot:

Adding audio

Copy the MP3 files to the folder assets

Add code for btnsound in the onClick method. Add the following lines so that when the btnplay button is clicked, it will execute the method named playSound(). This method will receive a string argument as the value of the sound file name to be played.

The soundfile array variable is the variable that stores the list of the mp3 filenames, while the screennumber indicates the current number on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required