Android Boot Camp for Developers Using Java, 3E

Slides:



Advertisements
Similar presentations
Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Advertisements

Chapter 1: Voilà! Meet the Android
Chapter 3: Engage! Android User Input, Variables, and Operations
Mobile Computing Lecture#13. Lecture Contents 2 Widgets  Creating App Widget  Unsupported/Supported Views/Layouts  Widget Layout  Widget Settings.
Chapter 6 Jam! Implementing Audio in Android Apps.
Chapter 6: Jam! Implementing Audio in Android Apps.
Android and Project Structure. Android Android OS – Built on Linux Kernel – Phones – Netbooks – Readers – Other???
CS371m - Mobile Computing Audio.
Android Development (Basics)
Basic Audio and Video. Audio Primary components – Audio file stored in ‘raw’ folder within ‘res’ folder ‘raw’ directory must be created while many formats.
Chapter 1: Voilà! Meet the Android. Smartphones –Can browse the Web –Allow you to play games –Use business applications –Check –Play music –Record.
Chapter 11 Adding Media and Interactivity. Flash is a software program that allows you to create low-bandwidth, high-quality animations and interactive.
CS378 - Mobile Computing What's Next?. Fragments Added in Android 3.0, a release aimed at tablets A fragment is a portion of the UI in an Activity multiple.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
Chapter 1: Voilà! Meet the Android
Chapter 10: Move! Creating Animation
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
DUE Hello World on the Android Platform.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Engage! Android User Input, Variables,
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
Android Boot Camp for Developers Using Java, 3E
Chapter 7: Reveal! Displaying Pictures in a Gallery.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Android Hello World 1. Click on Start and type eclipse into the textbox 2.
First Venture into the Android World Chapter 1 Part 2.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
CS378 - Mobile Computing Audio.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 10: Move! Creating Animation 1 Android.
Mobile SMIL Jason Daniels Ben Bedinghaus Ryan Ware.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
CS371m - Mobile Computing Audio. Audio on Device Devices have multiple audio streams: – music, alarms, notifications, incoming call ringer, in call volume,
Introduction to Android Chapter 1 1. Objectives Understand what Android is Learn the differences between Java and Android Java Examine the Android project.
Audio and Haptic Feedback
Chapter 2: Simplify! The Android User Interface
Android Application 2D Graphics cs.
Android Application Audio 1.
Lecture 7: Service Topics: Services, Playing Media.
MAD.
Activities and Intents
Anatomy of an Android App and the App Lifecycle
Creation of an Android App By Keith Lynn
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
The Android Activity Lifecycle
Android SDK & App Development
CS5103 Software Engineering
Android App Developing with communication included
CIS 470 Mobile App Development
Cannon Game App Android How to Program
Android Topics Android Activity Lifecycle and Experiment Toast
CIS 470 Mobile App Development
Lecture 7: Service Topics: Services, Broadcast Receiver, Playing Media.
Mobile Programming Dr. Mohsin Ali Memon.
Android Development Tools
Activities, Fragments, and Intents
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Android Boot Camp for Developers Using Java, 3E Chapter 6: Jam! Implementing Audio in Android Apps Android Boot Camp for Developers Using Java, 3rd Ed.

Objectives In this chapter, you learn to: Create an Android project using a splash screen Design a TextView control with a background image Pause the execution of an Activity with a timer Understand the Activity life cycle Open an Activity with onCreate( ) End an Activity with finish( ) Assign class variables Create a raw folder for music files Android Boot Camp for Developers Using Java, 3rd Ed.

Objectives (continued) Play music with a MediaPlayer method Start and resume music playback using the start() and pause() methods Change the Text property of a control Change the visibility of a control Android Boot Camp for Developers Using Java, 3rd Ed.

Implementing Audio The most common Smartphone activities Texting Talking Gaming Apps Multimedia Android Boot Camp for Developers Using Java, 3rd Ed.

Implementing Audio (continued) Steps to complete the app: Create a splash screen with a timer. Design a TextView control with a background image. Initialize a TimerTask and a timer. Launch a second Activity. Design a second XML layout. Add music files to the raw folder. Initialize the MediaPlayer class. Play and pause music with a Button control. Android Boot Camp for Developers Using Java, 3rd Ed.

Creating a Splash Screen A Splash Screen is a window that is displayed for a few seconds before the app opens The next screen opens automatically The Android initializes its resources and loads necessary files while the splash screen is displayed Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a Background Image to a TextView Widget Image is not an ImageView control - its a TextView control with a background image Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a Background Image to a TextView Widget (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a Background Image to a TextView Widget (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Creating a Timer A timer in Java can: Execute a one-time task like displaying an opening splash screen Perform a continuous process such as a morning wake-up call set to run at regular intervals Use two Java classes, named TimerTask and Timer Each time a timer runs it runs in a single thread A thread is a single sequential flow of control within a program Android Boot Camp for Developers Using Java, 3rd Ed.

Creating a Timer (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Creating a Timer (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Scheduling a Timer Android Boot Camp for Developers Using Java, 3rd Ed.

Scheduling a Timer Timers are scheduled in milliseconds 5000 milliseconds = 5 seconds Android Boot Camp for Developers Using Java, 3rd Ed.

Scheduling a Timer (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Life and Death of an Activity Each activity has a life cycle – a series of actions from the beginning of an Activity until its end When the activity begins, we use an onCreate() method to load it into memory When the activity ends, we use an onDestroy() method to remove it from memory Four states of an Activity: Active Pause Stopped Dead Android Boot Camp for Developers Using Java, 3rd Ed.

Life and Death of an Activity (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Life and Death of an Activity (continued) Ovals represent major states of the Activity Rectangles represent methods that can be implemented to perform operations Android Boot Camp for Developers Using Java, 3rd Ed.

Life and Death of an Activity (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Launching the Next Activity After the Splash Screen is destroyed an intent must request that the next Activity is launched Main.xml already exists as the default layout A second class named Main must be created before the code can launch this Java class Android manifest file must be updated to include the Main Activity Main Activity is responsible for playing music Android Boot Camp for Developers Using Java, 3rd Ed.

Launching the Next Activity (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Launching the Next Activity (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the activity_main.xml File Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the activity_main.xml File (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Class Variables Recall that local variables are declared within a method The scope of a variable refers to the variable’s visibility within a class When a variable is needed in multiple methods in a class, a global variable is used Global variables are called class variables Android Boot Camp for Developers Using Java, 3rd Ed.

Class Variables (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Class Variables (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Class Variables (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Class Variables (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Playing Music Android phones and tablets have built-in music players Androids can play audio and video from several data sources .mp3 files are most common Can also play .wav, .ogg, and .midi Uses codec technology to compress and decompress files Android Boot Camp for Developers Using Java, 3rd Ed.

Creating a Raw Folder for Music Files Android Boot Camp for Developers Using Java, 3rd Ed.

Using the MediaPlayer Class A MediaPlayer class provides the methods to control audio playback on Android devices Android Boot Camp for Developers Using Java, 3rd Ed.

Using the MediaPlayer Class Android Boot Camp for Developers Using Java, 3rd Ed.

The MediaPlayer State Android Boot Camp for Developers Using Java, 3rd Ed.

The MediaPlayer State (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the MediaPlayer Class (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the MediaPlayer Class (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Changing the Visibility Property Using Code The Visibility property is the Java property that determines whether a control is displayed on the emulator is Default Visibility property is set to display any control you place on the emulator when the program runs Android Boot Camp for Developers Using Java, 3rd Ed.

Changing the Visibility Property Using Code (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Changing the Visibility Property Using Code (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Summary Android apps can show a splash screen that displays program name, brand logo, or author name Splash screens open when an app launches TextView widgets display a background color or image Timers in Java execute a one-time task or perform a continuous process Timers must be scheduled to run – timed in milliseconds Android Boot Camp for Developers Using Java, 3rd Ed.

Summary (continued) Each Activity has a life cycle – a series of actions from the beginning of the activity to its end Local variables exist within a method and cease to exist when the method is finished Variable scope refers to a variable’s visibility within a class Every Android phone and tablet has a built-in music player Music files are typically stored in the res\raw subfolder - In newer versions of Android, you must create the raw subfolder before storing music files Android Boot Camp for Developers Using Java, 3rd Ed.

Summary (continued) The MediaPlayer class provides the methods to control audio playback on an Android device The Java property that controls whether a control is displayed on the emulator is the Visible property Android Boot Camp for Developers Using Java, 3rd Ed.