$29
Introduction
In this machine problem will learn how to start a new activity, read les, and perform multimedia operations.
Problem statement
Part I: Music Player App
In this part, you will learn how to use several GUI Widgets and the media player. This app will have a single activity. The user sees a vertical sequence of 3 radio buttons, each with a music le name next to it. When any radio button is clicked, the appropriate music should start playing, and a picture corresponding to the music (like a cover illustration) should appear below the radio buttons. Finally, a set of music control buttons (start/stop etc.) appears below the image.
Resources: Place three mp3 song les in \raw", and place three images corresponding to these songs in drawable.
XML: The layout of this app will consist of a title (TextView), a vertical list of radio buttons (Radio Group), an image (ImageView) and several buttons to control the player (start/stop Button).
JAVA: When the radio button is pressed, the corresponding music le must be played [2, 3], and the image in the ImageView is set to the one corresponding to the song that was clicked.
Part II: Quiz App
The objective is to start new activities corresponding to buttons pressed in MainActivity, and to pass data back and forth between the calling and called activities. This app will have two activities. The rst activity shows a list view with quiz topics. It also shows a score board of your performance thus far (initialized to 0), and a reset button. You must have at least 3 quiz topics.
When a quiz topic is clicked, a new activity opens that shows a question about that quiz topic, and presents an editText to enter the answer. The answer is veri ed, and control is passed back to the main activity which updates the scoreboard based on whether the answer was correct or wrong.
Resources: Add arrays of strings corresponding to questions and answers in \raw". More in le han-dling [4].
XML: The layout of the MainActivity will consist of a title (TextView), a vertical list of quiz topics (ListView), and a scoreboard (TextView) and a reset button (Button). The secondary activity layout con-sists of an app title (TextView), a TextView to display the question, an EditText to enter the answer, and a Button to press when you get done.
JAVA: When a quiz topic in main activity is pressed, the topic is sent via an intent to the secondary activity. The secondary activity identi es the topic from the intent, and displays a quiz question correspond-ing to the chosen topic. If the answer is entered correctly, a value of 1 sent back to the Main Activity. Else
1
the value of 0 is sent back. The scoreboard is updated, and the user may choose again.
First read through \Starting another Activity" in [1] and Chapters 7 and 8 in HFA [6]. You will also need to create LinearLayouts and GridLayouts for the appropriate display activities.
Don’t forget to declare your di erent display activities in the manifest (typically will happen automati-cally). You can read more on how to modify the Manifest on page 111 in HFA [6].
Evaluation Guidelines
Check operation using the interface.
Creativity carries bonus points.
Your application must run on either a physical or a virtual device.
References
Android developer: Building Your First App http://developer.android.com/training/basics/firstapp/index.html
Android developer: Building Apps with Multimedia http://developer.android.com/training/building-multimedia.html
Starting a media player after stopping. https://stackoverflow.com/questions/4486828/android-media-player-restart-audio-after-calling-stop
Android developer: Saving Data http://developer.android.com/training/basics/data-storage/index.html
Android developer: List View http://developer.android.com/guide/topics/ui/layout/listview.html
Head First Android
2