android app development 20150528

19
Android App Development 5 28 May, 2015

Upload: hideo-kadowaki

Post on 11-Aug-2015

161 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Android App Development 20150528

Android App Development 5

28 May, 2015

Page 2: Android App Development 20150528

Add a New Button LinearLayout (vertical)

Starting Another Activity Create the Second Activity goNextActivity() Method

Build an Intent Add a startActivity Method

Last Workshop

Page 3: Android App Development 20150528

Adding an Image Adding Audio

Today’s Contents

Page 4: Android App Development 20150528

Step 1 : Preparing an Image fileStep 2 : Adding <ImageView>

Adding an Image

Page 5: Android App Development 20150528

Supported Image Formats BMP / JPG / PNG / GIF

Image Folder Put your image file into folder

res/drawable

Step 1 : Preparing an Image file

Adding an Image

image01.jpg (300 x 255)

Page 6: Android App Development 20150528

Edit res/layout/activity_my.xml Add <ImageView> element

Step 2 : Adding <ImageView>

Adding an Image

res/drawable folder file extension can be omitted

Page 7: Android App Development 20150528

Adding an Image

Page 8: Android App Development 20150528

Adding Audio

Page 9: Android App Development 20150528

SoundPool an Android library

specifically targeted for playing short audio clips

Supported Audio Formats wav / ogg

Adding Audio

sound01.wav

MediaPlayer for longer sound files or streams

Page 10: Android App Development 20150528

Step 1 : Preparing an Audio fileStep 2 : Declaring VariablesStep 3 : Loading an Audio fileStep 4 : Playing an Audio fileStep 5 : Releasing SoundPool resources

Adding Audio

Page 11: Android App Development 20150528

Add raw folder under res folder

Put your audio file into folder res/raw

Step 1 : Preparing an Audio file

Adding Audio

Page 12: Android App Development 20150528

Edit MyActivity.java Declare 2 Variables in MyActivity class

Step 2 : Declaring VariablesAdding Audio

}

*To use SoundPool, import SoundPool class

Page 13: Android App Development 20150528

Edit MyActivity.java Add onResume() method to MyActivity

class

Step 3 : Loading an Audio file

Adding Audio

res/raw folderfile extension can be omitted

system calls this method when the activity comes to the foreground

Page 14: Android App Development 20150528

Edit MyActivity.java Add playAudio() method to MyActivity class

Edit res/layout/activity_my.xml Add onClick attribute to ImageView element

Step 4 : Playing an Audio fileAdding Audio

Page 15: Android App Development 20150528

Edit MyActivity.java Add onPause() method to MyActivity

class

Step 5 : Releasing SoundPool resources

Adding Audio

system calls this method when another activity is started

Page 16: Android App Development 20150528

Adding Audio

Page 17: Android App Development 20150528

Wrap Up for Today

Adding an Image ImageView element

Adding Audio SoundPool

Page 18: Android App Development 20150528

Follow the link and read the articles Android Activity Lifecycle

http://www.codelearn.org/android-tutorial/android-activity

Assignment

Page 19: Android App Development 20150528

fin.

2 more workshops left.