Android Topics Android Activity Lifecycle and Experiment Toast

Slides:



Advertisements
Similar presentations
CSE2102 Introduction to Software Engineering Lab 2 Sept/4/2013.
Advertisements

Chapter 6 Jam! Implementing Audio in Android Apps.
Chapter 6: Jam! Implementing Audio in Android Apps.
Android 02: Activities David Meredith
The Android Activity Lifecycle. Slide 2 Introduction Working with the Android logging system Rotation and multiple layouts Understanding the Android activity.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Android Life Cycle CS328 Dick Steflik. Life Cycle The steps that an application goes through from starting to finishing Slightly different than normal.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle.
Android Mobile computing for the rest of us.* *Prepare to be sued by Apple.
Android Info mostly based on Pro Android 3.  User Applications  Java Libraries – most of Java standard edition ◦ Activities/Services ◦ UI/Graphics/View.
DUE Hello World on the Android Platform.
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Noname. Conceptual Parts States of Activities Active Pause Stop Inactive.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
Speech Service & client(Activity) 오지영.
Android Programming.
Cosc 4735 Nougat API 24+ additions.
Lab7 – Appendix.
Android Application -Architecture.
Mobile Applications (Android Programming)
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Mobile Application Development BSCS-7 Lecture # 2
Activity and Fragment.
Adapting to Display Orientation
Basic Activities and Intents
Android Boot Camp for Developers Using Java, 3E
Activities, Fragments, and Events
Mobile Application Development BSCS-7 Lecture # 6
Android Dr. Vaishali D. Khairnar IT Department
XML Mihail L. Sichitiu.
MAD.
Activities and Intents
Anatomy of an Android App and the App Lifecycle
Android Mobile Application Development
The Android Activity Lifecycle
Broadcast Receivers A Android Component where you can register for system or application events, receive and react to broadcast intent. Each broadcast.
Android Introduction Camera.
Mobile Device Development
ANDROID UI – FRAGMENTS UNIT II.
CIS 470 Mobile App Development
Android Programming Lecture 9
CIS 470 Mobile App Development
Anatomy of an Android App and the App Lifecycle
Activity Lifecycle Fall 2012 CS2302: Programming Principles.
Cannon Game App Android How to Program
CMPE419 Mobile Application Development
Android Topics Custom ArrayAdapters Creating an Event Listener
Activities and Intents
Activities and Intents
HNDIT2417 Mobile Application Development
Android Programming Tutorial
Programming Mobile Applications with Android
CIS 470 Mobile App Development
Activity Lifecycle.
Activities and Intents
CIS 470 Mobile App Development
Activities and Intents
Mobile Programming Dr. Mohsin Ali Memon.
SE4S701 Mobile Application Development
CMPE419 Mobile Application Development
Android Development Tools
Korea Software HRD Center
Activities, Fragments, and Intents
Mobile Programming Broadcast Receivers.
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Android Topics Android Activity Lifecycle and Experiment Toast Explore Online Android Documentation Practice: In-Class App

Android Activity Every application has at least one activity class. A main activity is presented to the user when the application is launched for the first time. Example: Users of a banking app must first log into their accounts before they can pay bills or transfer money. Login is the main activity. Each activity can start another activity in order to perform different actions. Each time a new activity starts, the previous activity is paused and the Android system preserves its status.

Android Activity and the AndroidManifest.xml Activities must be declared in the AndroidManifest.xml file in order to be accessible to the system. The category of the main activity is specified as the top-levellauncher.

AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.trishcornez.mediaplayer"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

Activity Class callback methods 1. onCreate() 2. onStart() 3. onResume() 4. onPause() 5. onStop() 6. onRestart() 7. onDestroy() A callback method gets called when an event occurs.

Toast: Development feature Example A Toast can be programmed to appear when an event occurs, such as when the user clicks a button or when an activity is created. A Toast appears and then vanishes.

Experiment : Lab 3 Exercise 1

Objective of Exploring Online Documentation Navigate documentation Research constructs Build apps that we have very little clue about at the start.

Development Tips Never build an entire app and then test it. Build and test in increments. Use development tools, such as Android logs and Toast to aid your process. Android Logs: Following certain events, include a message to the Android logs. For the Log tag, use the name of activity class. For the Log message, use a keyword name and a value. Toast: Can be used to display a temporary message box to the screen.

In-Class App: Sound Player The app is loaded with a sound (Mad Cow) Sound can be played. Sound can be paused and then played again, continuing at the pause point. 

Where to begin? What do we know? Sound is a media element. This app requires MediaPlayer for Android. MediaPlayer will need to be researched. Sound is stored as raw data. Create a raw directory in the resources directory and load it with an interesting sound.

Controller View Model

Overview of Development Tasks Task 1: Build a Layout for the app. Task 2: Test the app using Toast. Quick experiment. Task 3: Research MediaPlayer for sound. Task 4: Load the app with an interesting sound. Task 5: Implement the MediaPlayer . Task 6: Test the app: play the sound, pause it, and continue playing it. Task 7: Remove Toasts when done. No Stop action is added to this app. It requires a little more finesse.

Task 1: Build a Layout for the app. Task 2: Test the button using Toast. Quick experiment.

Task 3: Research MediaPlayer for sound. What is MediaPlayer? Is it a class or an object? What does the MediaPlayer state diagram tells us about playback controls? How do we play a sound or pause a sound? How do we start the playback of a sound. How do we resume playback for a paused MediaPlayer object? What is required to to play a specific sound? How do we identify a raw file?

Task 4: Load the app with an interesting sound.

Task 5: Implement the MediaPlayer . Task 6: Test the app: play the sound, pause it, and continue playing it. Task 7: Remove Toasts when done.