android developer - music player from scratch gdg cebu devfest 2014

74
KEITH LEVI LUMANOG MUSIC PLAYER FROM SCRATCH Android Development for Noobs

Upload: keith-levi-lumanog

Post on 13-Jul-2015

467 views

Category:

Internet


2 download

TRANSCRIPT

KEITH LEVI LUMANOGMUSIC 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

ActionbarActivity ListActivity

Activity FragmentActivity

What to choose?

with Actionbar

1. CREATING A LIST VIEW

ListView

ListItem

ListItem Adapter

HIT RUN AND PREVIEW

ListItemsListView

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

Playadd this button

when clicked, plays the song and changes the text

to pause

Dynamic based on song title

or artist name

CREATING AN INTERFACE

Play

JAVA TIME!

mainactivity

Dynamic based on song titleDynamic based

on artist name

back button doesn’t workback button

doesn’t work

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!

the music keeps on playing! even minimised or when clicking back

PROBLEM?

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

THANK YOU!Keith Levi Lumanog