1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang.

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Android architecture overview
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android 101 Application Fundamentals January 29, 2010.
Google Android as a mobile development platform T Internet Technologies for Mobile Computing Olli Mäkinen.
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
1 Android: Event Handler Blocking, Android Inter-Thread, Process Communications 10/11/2012 Y. Richard Yang.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Mobile Application Development with ANDROID Tejas Lagvankar UMBC 29 April 2009.
About me Yichuan Wang Android Basics Credit goes to Google and UMBC.
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
CS5103 Software Engineering Lecture 08 Android Development II.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Chapter 2: Simplify! The Android User Interface
01. Introduction to Android Prof. Oum Saokosal Master of Engineering in Information Systems, South Korea
1 Mobile Software Development Framework: Android 2/23/2011 Y. Richard Yang.
ANDROID Presented By Mastan Vali.SK. © artesis 2008 | 2 1. Introduction 2. Platform 3. Software development 4. Advantages Main topics.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Designing user interfaces using: Simple views 1. Views Basic views – TextView – EditText – Button – ImageButton – CheckBox – ToggleButton – RadioButton.
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
1 Mobile Software Development Framework: IOS 10/2/2012 Y. Richard Yang.
Introduction to Android Programming
Android Programming.
Introduction to android
Mobile Device Development
CS434/534: Topics in Networked (Networking) Systems Mobile System: Android (Single App/Process) Yang (Richard) Yang Computer Science Department Yale.
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android Application Development 1 6 May 2018
Android N Amanquah.
GUI Programming Fundamentals
Android – Event Handling
Android Introduction Hello World.
ITEC535 – Mobile Programming
CMPE419 Mobile Application Development
HUJI Post PC Workshop 1 Introduction to Android Development Ari Sprung
תכנות ב android אליהו חלסצ'י.
Mobile Software Development Framework: Android
Android Programming Lecture 6
CIS 470 Mobile App Development
MultiUni Trần Vũ Tất Bình
Application Development A Tutorial Driven Course
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Project Structure, App Resources and Event Handling
Mobile Programmming Dr. Mohsin Ali Memon.
Android Development Introduction to Android Development 2011/01/16
CMPE419 Mobile Application Development
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang

2 Admin. r Homework 2 questions

3 Recap: TinyOS r Hardware components motivated design m Each component/module specifies –the interfaces it provides –the interfaces/modules it uses implements the functions in –the declared provided interfaces –event handlers in the declared used interfaces m Configuration specifies the linkage among components/modules r Execution model m Event driven (triggered) handlers, who may post tasks to a FIFO task queue monitored by a task thread

4 Recap: J2ME Framework r Java adaptation for mobile devices r A major focus of J2ME is device heterogeneity r Solution: versioning m Configurations m Profiles

5 Recap: J2ME MIDP Structure MIDP Lifecycle callbacks -startApp -pauseApp -destroyApp Current Displayable A set of commands Command listener d=Display.getDisplay(this) d.setCurrent(disp) disp.addCommand() disp.setCommandListener()

6 Recap: IOS r Apple’s adaptation for mobile devices r E.g., Cocoa => Cocoa Touch m App KIT => UI Kit neOSTechOverview/iPhoneOSTechOverview.pdf

7 Recap: IOS Model View Controller (MVC) Structure Model View Controller Model View Outlet Target Action did will Delegate count Data at Data source Notification and KVO

8 Discussion r What are some major differences between desktop GUI app design and mobile (phone/tablet) GUI app design?

9 Some Key Features of Mobile UI APp r Limited screen real estate m one thing at a time r Limited resources: more dynamic system management on app life cycle m give app chances to adapt, better mem management r More heterogeneous display devices m decoupling between display and logic

10 Mobile GUI App r Screen real-estate is limited => Focus on one thing at a time

11 Mobile GUI App r Screen real-estate is limited => Focus on one thing at a time

Mobile GUI App Workflow App App lifecycle callbacks/custom -start -pause -…

Mobile GUI App Workflow: Do One Thing App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y

Mobile GUI App Workflow: Display Content Based on Underlining Data App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y Data/ Model

Mobile GUI App Workflow: Handle Events App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y Data/ Model Event Handle r

Mobile GUI App Workflow: Switch to Another GUI App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y Data/ Model Event Handle r Display Composite Display Composite Display

17 Discussion r Key design points for mobile GUI app m Specify app life cycle customization m Specify display m Specify event scheduling How to link event, display, handler, data

Typical Design: App App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y Data/ Model Event Handle r Framework reacts to app events and invokes app lifecycle event handlers

19 How to Provide App LifeCycle Handlers? r App class implements it m Inheritance r App class does not implement it m Delegate m Command listener

Typical Design: UI App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y Data/ Model Event Handle r System captures UI events; and puts them in a msg queue of the app. A UI thread processes the queue

Example: IOS 10/ 4/1 2

22 How to Provide Display Component Event Handlers? r Display Component class implements it m Inheritance m Typically a bad idea r Display Component class does not implement it m Makes Display reusable Delegate Command listener

23 Outline r Admin and recap r Mobile/wireless development framework m GNURadio m TinyOS m J2ME m IOS m Android

Android r A mobile OS based on Linux m Customized Linux kernel 2.6 and 3.x (Android 4.0 onwards) E.g., default no X Windows, not full set of GNU libs m Apply OS concepts for mobile contexts e.g., each app is considered one Linux user m New key components, e.g., Binder for IPC Power management wakelock r Application development framework based on Java m Dalvik Virtual Machine 24

Android Architecture 25

Android Tools r Android SDK Manager (android) r Android emulator r Android debug bridge (adb) can connect to an Android device and start a shell on the device r See

Mapping to Android App App lifecycle callbacks/custom -start -pause -… Display Composite Displa y Composite Displa y Display Composite Displa y Data/ Model Event Handle r -How to specify the customized callbacks: extend Activity class -How to link the callbacks defined in view to listener/controller: View.set…Listener() Allows external XML resource files to specify views

Application Framework (Android): Key Concepts r Activity r View/ViewGroup (Layout) r External resources 28

Activity r A single, focused thing that the user can do. r Creating a window to place UI views m Full-screen windows, floating windows, embedded inside of another activity r Typically organized as a Stack m Top Activity is visible m Other activities are stopped m Back button to traverse the Activity Stack m Long Home shows the content of the Stack

Activity: Manifest File r To facility launching and managing Activities, each activity is announced in a manifest file Manifest the activity Instead of a hardcode string in code, defines in res/strings

Android Project Resources 31

Activity: Example // MainActivity.java public class MainActivity extends Activity public void onCreate(Bundle savedInstanceState) { // savedInstanceState holds any data that may have been saved // for the activity before it got killed by the system (e.g. // to save memory) the last time super.onCreate(savedInstanceState); setContentView(… ); // set a View }

View r A view component is a building block for user interface components. r Two types of views m Leaf: TextView, EditText, Button, Form, TimePicker… ListView m Composite (ViewGroup): LinearLayout, Relativelayout, …

Programmatic Usage of Views // MainActivity.java public class MainActivity extends Activity public void onCreate(Bundle savedInstanceState) { // savedInstanceState holds any data that may have been saved // for the activity before it got killed by the system (e.g. // to save memory) the last time super.onCreate(savedInstanceState); TextView tv new TextView(this); tv.setText("Hello!“); setContentView(tv); }

Define View by XML

Access View Defined by public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); } … TextView myTextView = (TextView)findViewById(R.id.myTextView); <LinearLayout xmlns:android=” /apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Hello World, HelloWorld” /> main.xml

External Resources r Compiled to numbers and included in R.java file 37

Hello Example r See HelloStart 38

39 Android Activity Life Cycle

Lifecycle Example r See ActivityifeCycle 40

Linking Views and Handlers/Controllers r onKeyDown. onKeyUp r onTrackBallEvent r onTouchEvent myEditText.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { … return true; } return false; }}); } registerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) {….}}

Example: TipCalc Set listener: 42 public class TipCalcActivity extends Activity implements OnClickListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tip_calc); Button calc = (Button)findViewById(R.id.calculate); calc.setOnClickListener(this); } … }

Example: TipCalc Handler: public void onClick(View arg0) { EditText amountText = (EditText)findViewById(R.id.amount_value); // get input double amt=Double.parseDouble(amountText.getText().toString()); // compute output double tipD = amount * 0.15; // set UI String tipT = String.format("%.2f", tipD); TextView tipText = (TextView)findViewById(R.id.tip_value); tipText.setText(tipT); }