KEITH LEVI LUMANOG 
MUSIC PLAYER FROM 
SCRATCH 
Android Development for Noobs
PLANNING STAGE
MUSIC PLAYER PLANS 
• create a list 
• add event on click on each list 
• pass data to the detail page 
• add play/pause button 
• play music 
• stop music when app is on background
Take time to think - take a nap , chill
0. HELLO WORLD
EASY ENOUGH? 
lets take a look at the code
GENERATED FILE STRUCTURE
What to choose? 
ActionbarActivity 
ListActivity 
Activity 
FragmentActivity
with Actionbar
1. CREATING A LIST VIEW
ListView 
ListItem
ListItem Adapter
HIT RUN AND PREVIEW
ListItems 
ListView
2. LISTITEM EVENTS
Item position 
One, zero index
3.PASSING DATA
What’s the problem with this code? 
MainActivity.java
WE NEED TO PASS MULTIPLE 
DATA 
1. mp3 file name 
2. song title
Change String to Object
That easy?
Create new Java Class
Logcat on events
Finally we can pass multiple data!
RECEIVING DATA
Dynamic based 
on song title 
Play 
Dynamic based 
on song title 
or artist name 
add this button 
when clicked, plays the 
song and changes the text 
to pause
CREATING AN INTERFACE
Play
JAVA TIME!
mainactivity
Dynamic based 
back button 
doesn’t work 
Dynamic based 
on song title 
on artist name 
chill lang usa diha
PlayActivity.java
Manifest file
New Manifest file 
Parent activity meta-data to support 4.0 and lower
PlayActivity.java
RUN AND RELAX
MUSIC PLAYER PLANS 
• create a list 
• add event on click on each list 
• pass data to the detail page 
• add play/pause button 
• play music 
• stop music when app is on background
PlayActivity.java
activity_play.xml
THAT’S IT?
put the mp3 files on the raw folder 
must be the same file name with the list object
PlayActivity.java 
why onResume?
Android Activity Life Cycle
RUN AND TEST!
PROBLEM? 
the music keeps on playing! even minimised or when clicking 
back
SOLUTION
THAT’S IT! 
make sure to test on an actual device
WHAT WE DIDN'T DO? 
• Android Studio installation 
• creating virtual devices 
• SDK installation 
• launcher icons
https://play.google.com/store/apps/details? 
id=webninja.com.simplemusicplayer
https://github.com/keithics/gdgcebu2014-musicplayer
Keith Levi Lumanog 
THANK YOU!

Android Developer - Music Player from scratch GDG Cebu DevFest 2014