Algorithms and OOD (CSC 207 2013F) : Labs

Laboratory: Making a Cat Go Meow!

In this laboratory you will practice adding and using resources, and giving your app a very simple functionality.


Make sure you've completed and understood the reading, Making Our Apps Do Things. You probably want to keep it up in a separate tab.


Exercise 1: Create a new Android Project

Create a new android project. Name it “Meowing Kitty”. Follow one of the package naming conventions we've discussed in previous readings.

Exercise 2: Gathering resources

a. Grab your favoirte picture of a cat or kitten.

b. Download your favourite meowing noise here: Make sure to Download the mp3 version

Exercise 3: Importing resources

a. You should already know where to put your image file, but make sure to rename it if it uses capital letters or special characters

b. To add a sound to your resources, you have to make a new folder called "raw"

c. Now drag your sound file to the folder, and rename it if neccessary

Exercise 4: Using resources

a. Add your picture and a button to your application

b. Feel free to use whatever layout you prefer, but give your layout elements the appropriate attributes and make sure you create the neccessary Strings to accompany them

c. Using the second method we discussed in the reading for adding functionality to a layout element, connect you button to a method that displays a simple "Meow" message to the user when clicked

Exercise 5: Dealing with sound files

a) As you did with the button, add an attribute to your ImageView that defines what happens when it's clicked

b. The process of having a method play a sound, is very similar to the one of creating our simple message

Replace the Toast object with a MediaPlayer. You'll need to import that class, or Eclipse will be upset.

c. The method to call instead of makeText is create, and its parameters are Context and the resource ID of the sound file

d. If you've forgotten how to get the resource ID of a file in the res folder, remember the R class (you need to omit the .mp3 part when refering to the file's name)

e. We can't really “show()” a MediaPlayer, but we can “start()” it

Exercise 6: See your app in action

a. Save all the files, compile and run the app

b. If it fails, talk to your mentor or instructor

For Those With Extra Time

Find a way to make the cat stop miaowing.

Copyright (c) 2013 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.