Note: This was written in early 2010, many things have changed.
Ok so let's get started…first lets download the Android SDK .
Start by downloading the zip file for windows, and saving it somewhere on your computer and then extract it. Then download Eclipse , I used "Eclipse IDE for Java EE Developers " (Galileo) and extract it. In order for Eclipse to function properly, you will need to ensure that you have Java installed. If you do not have Java, Click Here to download it. If you aren't sure if you have Java, Click here to check if it is installed . After extracting Eclipse, open the eclipse folder and launch eclipse.exe. When you open eclipse it will ask you to choose a "workspace", this will be the directory where all of your project files will go.
Once eclipse is open select the Help menu and go to "Install New Software". Next to the top dropdown bar there is a button that says "Add", click on "Add" and name the remote site something. For the address put in https://dl-ssl.google.com/android/eclipse/ And then click OK (If this fails, try changing the HTTPS to HTTP). After a moment the box in the middle will populate with "Developer Tools". Check the box next to developer tools and then click next, then on the "Install Details" screen click next again, on the "Review Licenses" screen, read and accept the license agreement and then click Finish. Now Eclipse will download and install the ADT , just wait for this process to finish. During this process you may receive a warning saying "You are installing software that contains unsigned content. The authenticity…..etc" Select OK for this and continue to install the software.
Once the software has completed installing, it will ask you if you would like to restart the program now, choose the Yes option. Now that we have everything installed, we need to tell Eclipse where the android SDK is located and create an android virtual device. In Eclipse select Window->Preferences then on the left hand side choose Android. You will receive an error message about Eclipse not knowing where the Android SDK is located, click OK to this message. In the center of the box you will see something that says "SDK Location" and it has a browse button next to it, click Browse and then point it to the android-sdk-windows folder . After you've pointed it to the android SDK folder click apply and then OK.
Then from Window drop down menu in Eclipse, choose "Android SDK and AVD Manager", it will bring up a new window with a few choices. First of all, we need to get the Android OS. Select the "Available Packages" on the left and then click the small arrow next to the google.com entry that is listed under "Sites, Packages and Archives". This should then show a list of different Android software and documentation. In order to maintain as much compatibility between devices as possible, we will use API3 since it will support Android 1.5 and above . Once you've selected the API3 options, click on Install Selected . You will then need to accept the package and license agreement for those packages and click on install accepted (The radio button "Accept All" will apply to all downloads. Now the Android SDK and AVD Manager will download and install the documentation and software for API3 (if that's what you picked), this can take a few minutes on high speed connections, and could take an extremely long time on a dial up connection, just wait for the process to finish).
When the process finishes, it will ask you if you want to restart the ADB, click on Yes. When the ADB has been restarted click on Virtual Devices on the left and then click the New button on the right. Name the device whatever you would like, drop down the Target and select "Android 1.5 API Level 3", for Size put 500 MiB and then finally click on "Create AVD". Now that we have created an android virtual device, you can close the Android SDK and AVD Manager and return to Eclipse.
Now we have the entire environment setup, the rest is easy. Download the Sound Board Template
and save it somewhere, then extract it. In Eclipse select File->Import expand General and choose Existing Projects Into Workspace and then browse to where you just extracted the SoundBoard Template , then click finish.
At the bottom area of the screen there is a tab called Console, look in this tab and see if you see any errors. If you see a message that says “Android requires .class compatibility set to 5.0. Please fix project properties.” Follow these steps, If you do not see this message skip to the next step.
On the left in the Project Explorer, expand sound board Template, expand src, expand src.soundboard, double click on Soundboard.java You will notice on like 15ish there is a line that says “@Override” and it should have a red squiggly line below it. Mouse over it and you will be given the option to Change project or workspace to JRE 1.5. Select Change Project to JRE 1.5
By default, this soundboard is configured for 30 sounds. If you want more or less you will need to modify the code so here are the steps to putting in your own sounds. First, gather all of your sounds in a directory and convert them to OGG using Audacity just open them up, and then save them in OGG format. You will need to rename them to match the definitions in the code, the naming convention is sound#.ogg (sound1.ogg sound2.ogg sound3.ogg etc) If you don’t want to rename them, then you will need to change the sound names in Soundboard.java Once you have converted all your sounds to ogg, copy them into the res\raw folder in the sound board folder.
Here is how this works… the file named sound1.ogg is defined as sound number 1, and will play when button number 1 is clicked (because button 1 and sound 1 are linked through soundboard.java).
On the left side of Eclipse under Project Explorer, expand res, expand layout and double click on main.xml This will bring up the layout screen, notice that there are two tabs in this little mini window, one that says Layout, and one that says main.xml, switch over to the main.xml tab.
In the main.xml tab we see the xml layout of the application, no need to focus on understanding the code (unless you want to) as this is very simple editing.
Step 4: Putting your sounds into the board
So lets say you have…
Sound1.ogg – a sound that plays a phone ringing Locate where it says
<Button
android:id="@+id/sound1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 1"
>
</Button>
The code above is the XML for button1, the id’s and mappings have already been done for you so all you need to do is change “Sound Button 1 ” to whatever text you would like. So if sound1.ogg is the sound of a phone ringing, then you would change the “Sound button 1” text to say “phone ringing ”. Then by clicking on that button once the app is installed, it would play sound1 which would be a phone ringing. You would repeat this process for all the other sounds that you want to use.
Step 5: Adding more sounds
If you want to add more sounds…
you need to add lines to main.xml and Soundboard.java, below are examples of what you would add for sound 31, you would repeat this process for each sound after 31 changing the numbers for each one.
In main.xml add the following to the end of the file *before the </TableLayout> line *
<Button
android:id="@+id/sound31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 31"
>
</Button>
In Soundboard.java you would need to add the following lines (near the similar entries)
mSoundManager.addSound(31, R.raw.sound31);
Near the end of Soundmanager.java you would also need to add a function to allow the button to play sound 31, that would look like this
Button SoundButton31 = (Button)findViewById(R.id.sound31);
SoundButton31.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(31);
}
});
Ensure that you place it *before* the two }’s that come at the end, but after the }); from the previous entry so these would be what the last lines of the file would look like with a button 31
Button SoundButton30 = (Button)findViewById(R.id.sound30);
SoundButton30.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(30);
}
});
Button SoundButton31 = (Button)findViewById(R.id.sound31);
SoundButton31.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(31); }
});
}
}
To remove buttons and sounds from the template…
Open main.xml and delete whatever buttons you no longer want to use starting from the <button tag all the way to the </button> tag. So if you wanted to remove button number 30, you would delete the following code from main.xml
<Button
android:id="@+id/sound30"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 30"
>
</Button>
Once button 30 was removed, you would also need to remove the code references to it in soundboard.java Do this by opening Soundboard.java and locate the lines associated with ID30. We would remove the following lines from soundboard.java to get rid of sound number 30.
DELETE:
mSoundManager.addSound(30, R.raw.sound30);
Then scroll down to the button ID’s as 30 (indicated by Button SoundButton30) and remove the entire function that runs sound button 30. So you would DELETE:
Button SoundButton30 = (Button)findViewById(R.id.sound30);
SoundButton30.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSoundManager.playSound(30);
}
});
After removing those sections of code, all references to button 30 would be gone.
Okay so you've got all your sound files in the res/raw directory. You've removed or added buttons based on your needs. We're just a few steps away from being complete.
First, if you want to add a custom icon to your program, find your image and resize it to 72x72 and save it in a PNG format. Then copy that image to the res/drawable directory, replacing the one that is already there.
Once you have everything set just the way you want it, be sure to test your application by right clicking on "Sound Board Template" on the left and selecting Run As->Android Application. This will start up the virtual android device that you created and run your application in it. (Note: it usually take a few minutes for the virtual android to boot up and load the application so be patient).
Once you have tested it in the emulator and you are sure that it works, go to file->export. Then click the arrow next to the android folder and select Export Android Application. On the next screen, click browse and select the soundboard application and then click next.
In order to export it, we must create a key store. Click the browse button and select a location to place your key store and then choose a password and type it in the password and confirm password fields.
On the Key Creation screen you must specify an alias, a password, a validity time, and at least one of the additional information fields. The validity time should be at least 25 years.
Finally it will ask you where to put the APK file that you want to export. The APK file is what you will need to copy onto the Android device to install. Once you picked a place click finish.
We are nearly there... Plug your Android phone into the computer via USB and using the pull down menu, mount the phone as a drive. Once this is done, copy the APK file over to your phone into the download or bluetooth folders. In order to install the application we need one more thing, go to the android market and download Astro file manager. Once that is installed go into Menu->Settings->Applications and check the box that says Unknown Sources. You will be given a message indicating that this could be a dangerous setting, click OK to continue. After doing that open up Astro, navigate to where your new application is and click on it. It will tell you that its an application file, select the option that says "Open App Manager". From there theres a button that says install, click it and your new app is installed. NOTE: Return to Menu->Settings->Applications and uncheck the box that says Unknown Sources.
Thanks for checking out the Android Soundboard Walkthrough. I hope you all found something helpful here. If You've got any comments about this walkthrough or would like to add something to the FAQ, please email me at Daxx@IgnoranceIsFutile.com NOTE: I am no longer providing E-Mail support for this walkthrough, Sorry.
Q: Everytime I load my soundboard, the sound stops after a few seconds! Whats up with that?
A: To resolve this, save your OGG files at 11025 HZ 16-bit.