teaching machines

Homework 1 – 8BitKnowledge

September 30, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

My android flashcard application is a quiz of one’s knowledge of classic video game clips.

The app is pretty straightforward. I created a class (Audio Container) that holds, randomizes, and serves all of the audio clips to the main activity. The main activity holds the overall game logic, comparisons between a user’s entered text, as well as keeps track of scores.

Some hurdles that I had to jump through while developing was the usage of the MediaPlayer object with URI’s instead of static references to the audio files. Because the clips were all held in random order in the AudioContainer, I had to use some interesting syntax to be able to create a new URI each time a clip needed to be served (whenever the submit button was pressed).

Uri soundLocation = Uri.parse("android.resource://edu.uwec.cs.cs491.homework1/raw/" + soundFilename);

Having to address files in the raw directory using the package name and location seemed unintuitive, but it’s the only solution that I found that worked.

I also added a tiny bit of embellishment to the app by creating an ImageButton *gasp*. The creation and use of the imageButton is pretty much identical to a regular android Button, unfortunately ImageButton isn’t a subclass of Button (as I had assumed when creating the action listener for it), so changing from a Button to an ImageButton isn’t so cut and dry.