SlideShare uma empresa Scribd logo
1 de 76
Baixar para ler offline
HIT3328 / HIT8328 Software Development for
Mobile Devices
Dr. Rajesh Vasa, 2011
Twitter: @rvasa
Blog: http://rvasa.blogspot.com
1
Lecture 04
Complex
Interactions
R. Vasa, 20112
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (using Global Variables)
ā€¢Application Manifest File
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 20113
Android Device User
Interaction
Menu
HomeBack
R. Vasa, 20114
Android App. is made of
Activities
Activity
View Group
Views
(Layout)
R. Vasa, 20115
User Interface (generally) Built
in XMLActivity
View Group
(Layout)
Activity Class (Java)
Layout Definition
(main.xml)
PresentatioPresentatio
nn
FunctionaliFunctionali
tyty
R. Vasa, 20116
The Android Way - Convention not
Config.
ā€¢Source code (src)
ā€¢Generated code (gen)
ā€¢Resources (res)
ā€¢Images (@drawable)
ā€¢Layout of app (layout)
ā€¢Constants/Strings (@strings)
Conventions to Follow
R. Vasa, 20117
Portrait and Landscape Layouts
Conventions to Follow
R. Vasa, 20118
Provide Resources @Multiple
Resolutions
High
Low
Medium
Conventions to Follow
R. Vasa, 20119
View Identifiers
@+id TAG creates new identifiers
Conventions to Follow
R. Vasa, 201110
UI Interaction Handling Pattern
ā€¢Component.setOn......Listener ( handler
)
ā€¢E.g. button.setOnClickListener
ā€¢Handler is an anonymous inner class
ā€¢On...Listener handler = new
On....Listener() {}
R. Vasa, 201111
Android Activity Life Cycle
onCreate is called
when Activity Starts
Activity is
re-started
when
orientatio
n
changes
R. Vasa, 201112
We Retrieve State On Creation
State retrieval
done here
onSaveInstanceState(
) is called from this
state
(Save Saved here)
R. Vasa, 201113
Bundle stores simple state
information
BundleBundle
putString(key, value)
putDouble(key, value)
putInt(key, value)
putStringArray(k
ey, value[])
It is a Key, Value store system
(like a Hash Table or a Hash Map)
Code Snippet:
state.putString("inputTemperature", inputTemp);
Code Snippet:
state.putString("inputTemperature", inputTemp);
R. Vasa, 201114
Working with Resources
off.png
Layout XML File
Via Java Code
on.png
R. Vasa, 201115
Short Problem 1 - Passing Data
ā€¢Context: In Android -- Apps are made of
Activities. So, each Screen is a ā€œnewā€
Activity
ā€¢ We want to pass data between Activities.
ā€¢ But, Activity construction is managed by the
Dalvik runtime. That is, cannot pass data into
constructor.
ā€¢What would you prefer to do?
ā€¢ Store shared data in global variables available to
ALL Activities.
ā€¢ Move all data to a separate data layer.
ā€¢ Send primitive data bundles between
R. Vasa, 201116
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (using Global Variables)
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201117
Wiring up Activities -- Typical
Use Case
Select
Back
Contact List Activity Contact Details
R. Vasa, 201118
Wiring up Activities -- Typical
Use Case
Select
Contact List Activity Contact Details
We re-use this
activity with
different data
Select
R. Vasa, 201119
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing options
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (using Global Variables)
ā€¢Passing Data Demo (using Intents)
R. Vasa, 201120
Data Passing Option - Global
Variables
ā€¢We can use Global Variables ... but,
ā€¢Widely accepted as a ā€œriskyā€ choice
ā€¢A few global variables are used in many
large systems (e.g. Linux Kernel Source
Code)
ā€¢Risk manageable in ā€˜smallā€™ programs
ā€¢Good thread @ StackOverflow
http://goo.gl/EouH3
ā€¢Constant values as globals is ok (e.g.
R.java)
ā€¢Key Issue (to manage): How many objects
R. Vasa, 201121
Data Passing Option - Data
Layer
ā€¢We can store all data in a DBMS and access
it via a ā€œdata layerā€
ā€¢Good idea when dealing with large /
complex blocks of data
ā€¢Overkill if we only need to store a few values
ā€¢The data store can be ā€œin-memoryā€,
ā€œon-diskā€, and/or ā€œon remote serverā€
R. Vasa, 201122
Data Passing Option - Bundles
ā€¢We can put data into a bundle and pass
this across using a ā€œmessaging
frameworkā€
ā€¢Simple (once you understand the messaging
framework architecture)
ā€¢Persistence is not managed (like DBMS)
R. Vasa, 201123
Data Passing Option - iOS
Only!!
ā€¢You can pass data directly to methods in
another screen (UIViewController)
ā€¢UIViewController is approx. similar to Activity
ā€¢This option is not possible in Android -- this
was a ā€œdesign intentā€ (design side-effect?)
R. Vasa, 201124
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (using Global Variables)
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201125
iOS Apps. are directly managed
by O/S
UIAppDelegateUIAppDelegate
UIViewController-UIViewController-
AA
UIViewController-UIViewController-
BB
UIViewController-UIViewController-
CC
UIAppDelegate has Life
CycleView Controllers are
managed by the App
internally
Image Source: Apple Inc.
Life Cycle => Managed by Operating
System
R. Vasa, 201126
Android Activities are Managed by
O/S
Activity-AActivity-A
Activity-CActivity-C
Activity-BActivity-B
ApplicatiApplicati
onon Activities have
a parent
application
Activity has Life CycleApplication is NOT
managed directly by
the O/SLife Cycle => Managed by Operating
System
R. Vasa, 201127
A Key Design Different (iOS Vs
Android)
Activity-AActivity-A
Activity-CActivity-C
Activity-BActivity-B
UIAppDelegateUIAppDelegate
UIViewController-UIViewController-
AA
UIViewController-UIViewController-
BB
UIViewController-UIViewController-
CC
ApplicatiApplicati
onon
UIAppDelegate has Life
Cycle
Activities have
a parent
application
Activity has Life CycleApplication is NOT
managed directly by
the O/SLife Cycle => Managed by Operating
System
View Controllers are
managed by the App
internally
R. Vasa, 201128
Activity Life Cycle Design
Choice....
ā€¢Android developers decided to give Activity
a life cycle (rather than the application)
ā€¢This makes each Activity similar to a
separate program
ā€¢Hence, data passing is restricted to:
ā€¢Global Variables (stored in Application
object)
ā€¢Data bundles passed via async. messages
ā€¢Data stored externally in files or DBMS
R. Vasa, 201129
Short Problem 2 - Activity Design
Choice
ā€¢Unlike iOS ViewControllers, Activities have
been modelled to be (almost) like
independent programs
ā€¢What is the likely rationale for such a
choice?
ā€¢What would be the benefits?
R. Vasa, 201130
Only One Activity is
Active/Running
ā€¢Only one Activity can
be in the ā€˜foregroundā€™
ā€¢When Activity-A calls
Activity-B
ā€¢Activity-B will be visible
to the user
(foreground)
ā€¢Activity-A is paused
(background)
R. Vasa, 201131
Activities are Stacked in
Android
ā€¢All created activities are placed on a Stack
ā€¢Activities ā€˜poppedā€™ when ā€˜Back Buttonā€™ is
pressed
Activity-AActivity-A
Foreground/Acti
ve
If only one activity
is on the Activity
Stack then ā€œbackā€
button exits it
R. Vasa, 201132
Activities are Stacked in
Android
ā€¢All current activities are placed on a Stack
ā€¢Newly started activities come into
foreground
Activity-AActivity-A
Activity-BActivity-B
Foreground/Acti
ve
starts
Background/
Paused
Back button will
pop top most
activity from
stack
R. Vasa, 201133
Activities are Stacked in
Android
ā€¢As additional activities are started, older
activities go into background
ā€¢All activities are placed on Activity Stack
Activity-AActivity-A
Activity-BActivity-B
Activity-CActivity-CForeground/Acti
ve
starts
starts
Background/Pause
d
R. Vasa, 201134
Short Problem 3 - Activity
Stacking
ā€¢Consider the following situation,
Activity-AActivity-A
Activity-BActivity-B
Activity-CActivity-C
starts
starts
Activity-AActivity-A
starts
Are these activities
the same object?
Ponder the interaction design
implications .....
Will Back Button Exit the
App?
R. Vasa, 201135
Lets get our feet wet
R. Vasa, 201136
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (using Global Variables)
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201137
Demo 1 - Life Cycle of an Android
App.
ā€¢Walk-through of code provided along with
lecture handout.
ā€¢We can see the states by adding a little bit
of logging code to a few call-backs
R. Vasa, 201138
Life-Cycle Demo
onCreate, onStart,
onResume etc. are from the
Activity class
R. Vasa, 201139
Life-Cycle Demo (Watching
State)
R. Vasa, 201140
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (Global Variables)
ā€¢Application Manifest File
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201141
Demo 2 - Passing Data
R. Vasa, 201142
Before data passing -- a quick
recap
ā€¢This app. makes use of nested layouts
ā€¢We can also make it look a bit nicer using
weights
R. Vasa, 201143
Anatomy of the App. (Nested
Layout)
Linear Layout
TextView
ImageView
Linear Layout
Button (Fruit)
Button (Vegetable)
Button (Drink)
R. Vasa, 201144
A Weighty Problem
Spot the difference in layout
How achieved? android:layout_weight=ā€1ā€
for all buttons in the layout
R. Vasa, 201145
Layout Weights are Handy
If all buttons are given the
same weight, then they will
be of same size
R. Vasa, 201146
Demo 2 - Passing Data
Activity - FoodMain Activity - FoodView
Data Passed:
Name (ā€œFruitā€)
Image (fruit.png)
R. Vasa, 201147
Passing Data with Globals
ā€¢All Activities have a parent Application
object
ā€¢We can store data in this Application object
Activity-AActivity-A
Activity-CActivity-C
Activity-BActivity-B
ApplicatiApplicati
onon Activities have
a parent
application
We need to
extend the
Application class
to do this
R. Vasa, 201148
What Creates/Manages
Application?
ā€¢Application is created and managed by the
Android runtime
ā€¢There is one Application object created by
default
ā€¢We can extend the ā€œApplication Classā€ and
make our own
ā€¢But, we need to tell the Runtime about this
Application object via the Manifest XML
file
R. Vasa, 201149
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (Global Variables)
ā€¢Application Manifest File
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201150
Manifest contains Application
Metadata
ā€¢ Android runtime creates the Application object
ā€¢ Application metadata is provided in the Manifest
XML
Manifest XML file is
part of the project
Auto-generated by Eclipse IDE
R. Vasa, 201151
Manifest XML - What is it?
Manifest informs Runtime about the App.Manifest informs Runtime about the App.
R. Vasa, 201152
Manifest XML - Contents
Application Name
R. Vasa, 201153
Manifest XML - Contains
Activity Names
Activity Name(s)
R. Vasa, 201154
Manifest XML - Refers to Icons
Launcher Icon
R. Vasa, 201155
Manifest XML - Refers to the
App. Name
Application
Label
R. Vasa, 201156
Passing Data with Globals
ā€¢All Activities have a parent Application
object
ā€¢We can store data in this Application object
FoodApplicatiFoodApplicati
onon
ApplicatiApplicati
onon
We need to
extend the
Application class
to do this
extends
R. Vasa, 201157
Global Vars. can be in the
Application
FoodApplicatiFoodApplicati
onon
ApplicatiApplicati
onon
extends
R. Vasa, 201158
Activities and Globals in
Application
ā€¢Activities can access data from the
Application object
We can also get to these variables from any Activi
(declared in the Manifest XML file)
We can also get to these variables from any Activit
(declared in the Manifest XML file)
R. Vasa, 201159
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (Global Variables)
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201160
Demo 2 - Passing Data using
Intents
Activity - FoodMain Activity - FoodView
Data Passed:
Name (ā€œFruitā€)
Image (fruit.png)
R. Vasa, 201161
Wiring up the Buttons (Another
Way)
Buttons
support onClick
in the layout
XML
Buttons
support onClick
in the layout
XML
R. Vasa, 201162
Storing Data in a Bundle
R. Vasa, 201163
Sending an Async. Message
Android uses an asynchronous messaging
model (known as Intents) to send messages
between Activities
Android uses an asynchronous messaging
model (known as Intents) to send messages
between Activities
R. Vasa, 201164
Sending an Async. Message
Setup Message and Store
Data in the Message
Setup Message and Store
Data in the Message
R. Vasa, 201165
Sending an Async. Message
Class that is sending
the Intent (message)
Class that is sending
the Intent (message)
R. Vasa, 201166
Sending an Async. Message
Class that will receive
the Intent (message)
Class that will receive
the Intent (message)
Class that is sending
the Intent (message)
Class that is sending
the Intent (message)
R. Vasa, 201167
Sending an Async. Message
Send the Message to the Activity
(Transmit)
Send the Message to the Activity
(Transmit)
R. Vasa, 201168
Message Receiving
Retrieve data from the
message
Retrieve data from the
message
R. Vasa, 201169
Intent Messages are
Asynchronous
ā€¢The intent system is completely
asynchronous -- similar to e-mail
ā€¢That is,
ā€¢The receiver will get the message only if
they request to see intents via getIntent()
method
ā€¢All transmitted messages are placed on a
ā€˜Service Queueā€™
R. Vasa, 201170
Complex Domain Models
ā€¢Where do you hold a complex domain
model?(E.g. we have 4-5 classes in a
domain model)
ā€¢We can hold a reference to the domain
model objects in the Application
ā€¢This is fine if there are only a few objects
ā€¢Unlike Activity, Application is only terminated
if device runs low on memory
ā€¢If the data size is larger -- then best to use
the sqlite database
R. Vasa, 201171
Lecture Overview
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (Global Variables)
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201172
Controlling Input Data Type
ā€¢A common task on forms is to restrict users
to certain data types
ā€¢Email Address
ā€¢Decimal Numbers
ā€¢Positive Integers
ā€¢Alpha Numeric
ā€¢On mobile devices -- development
platforms offer a simple way to control the
keyboard type
R. Vasa, 201173
Controlling Input Type
(Android)
ā€¢Android has a large number of options
ā€¢You can merge them to create more
complex input types
textUri
textEmailAddress
textPassword
textPersonName
number
numberSigned
numberDecimal
numberPassword
textUri
textEmailAddress
textPassword
textPersonName
number
numberSigned
numberDecimal
numberPassword
android:inputTypeandroid:inputType
R. Vasa, 201174
Input Type - Example
http://developer.android.com/reference/android/widget/TextView.html#attr_andro
id:inputType
More info. at the following URL
R. Vasa, 201175
Lecture Recap
ā€¢Recap (previous 2 weeks)
ā€¢Passing Data between Activities
ā€¢Data passing methods
ā€¢Activity Design Choice
ā€¢Activity Life Cycle
ā€¢Passing Data Demo (Global Variables)
ā€¢Passing Data Demo (using Intents)
ā€¢Controlling Input Type
R. Vasa, 201176
Whatā€™s next?
ā€¢Usability Principles - Mobile Form Design
ā€¢Using Dialogs
ā€¢Returning data back from an Activity
ā€¢Simple File I/O
ā€¢More complex layouts
ā€¢Exploring a few more widgets

Mais conteĆŗdo relacionado

Mais procurados

Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
Chamnap Chhorn
Ā 

Mais procurados (20)

RDF ź°œė… ė° źµ¬ė¬ø ģ†Œź°œ
RDF ź°œė… ė° źµ¬ė¬ø ģ†Œź°œRDF ź°œė… ė° źµ¬ė¬ø ģ†Œź°œ
RDF ź°œė… ė° źµ¬ė¬ø ģ†Œź°œ
Ā 
Simple object access protocol(soap )
Simple object access protocol(soap )Simple object access protocol(soap )
Simple object access protocol(soap )
Ā 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
Ā 
Introduction to Web Services
Introduction to Web ServicesIntroduction to Web Services
Introduction to Web Services
Ā 
Web application framework
Web application frameworkWeb application framework
Web application framework
Ā 
Use Case Modeling
Use Case ModelingUse Case Modeling
Use Case Modeling
Ā 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
Ā 
Introduction - Web Technologies (1019888BNR)
Introduction - Web Technologies (1019888BNR)Introduction - Web Technologies (1019888BNR)
Introduction - Web Technologies (1019888BNR)
Ā 
jQuery
jQueryjQuery
jQuery
Ā 
Service Oriented Architecture (SOA)
Service Oriented Architecture (SOA)Service Oriented Architecture (SOA)
Service Oriented Architecture (SOA)
Ā 
Web search Technologies
Web search TechnologiesWeb search Technologies
Web search Technologies
Ā 
Introduction to webservices
Introduction to webservicesIntroduction to webservices
Introduction to webservices
Ā 
WSDL
WSDLWSDL
WSDL
Ā 
An Introduction to Semantic Web Technology
An Introduction to Semantic Web TechnologyAn Introduction to Semantic Web Technology
An Introduction to Semantic Web Technology
Ā 
Web services and SOA
Web services and SOAWeb services and SOA
Web services and SOA
Ā 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
Ā 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
Ā 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Ā 
MVC architecture
MVC architectureMVC architecture
MVC architecture
Ā 
IDEF0 and Software Process Engineering Model
IDEF0 and Software Process Engineering ModelIDEF0 and Software Process Engineering Model
IDEF0 and Software Process Engineering Model
Ā 

Destaque (10)

HIT3328 - Chapter01 - Platforms and Devices
HIT3328 - Chapter01 - Platforms and DevicesHIT3328 - Chapter01 - Platforms and Devices
HIT3328 - Chapter01 - Platforms and Devices
Ā 
Presentazione progettoglobale
Presentazione progettoglobalePresentazione progettoglobale
Presentazione progettoglobale
Ā 
Ambiente manuale orto_sinergico_rilegato
Ambiente manuale orto_sinergico_rilegatoAmbiente manuale orto_sinergico_rilegato
Ambiente manuale orto_sinergico_rilegato
Ā 
Postmodernizm prezentacja
Postmodernizm prezentacjaPostmodernizm prezentacja
Postmodernizm prezentacja
Ā 
Manifesto ecovillaggiosubbiano
Manifesto ecovillaggiosubbianoManifesto ecovillaggiosubbiano
Manifesto ecovillaggiosubbiano
Ā 
Momentum
MomentumMomentum
Momentum
Ā 
Per unmondonuovo
Per unmondonuovoPer unmondonuovo
Per unmondonuovo
Ā 
EduBrand Alumni Loyalty Program
EduBrand Alumni Loyalty ProgramEduBrand Alumni Loyalty Program
EduBrand Alumni Loyalty Program
Ā 
HIT3328 - Chapter03 - Simple Interactive Apps
HIT3328 - Chapter03 - Simple Interactive AppsHIT3328 - Chapter03 - Simple Interactive Apps
HIT3328 - Chapter03 - Simple Interactive Apps
Ā 
ę±Ÿå—é¢Øé›²éŒ„čˆ‡äŗŒę³‰ę˜ ęœˆ
ę±Ÿå—é¢Øé›²éŒ„čˆ‡äŗŒę³‰ę˜ ęœˆę±Ÿå—é¢Øé›²éŒ„čˆ‡äŗŒę³‰ę˜ ęœˆ
ę±Ÿå—é¢Øé›²éŒ„čˆ‡äŗŒę³‰ę˜ ęœˆ
Ā 

Semelhante a HIT3328 - Chapter04 - Complex Interactions

HIT3328 - Chapter0602 - Sketching Apps
HIT3328 - Chapter0602 - Sketching AppsHIT3328 - Chapter0602 - Sketching Apps
HIT3328 - Chapter0602 - Sketching Apps
Yhal Htet Aung
Ā 
HIT3328 - Chapter0701 - Dialogs, Tabs and Lists
HIT3328 - Chapter0701 - Dialogs, Tabs and ListsHIT3328 - Chapter0701 - Dialogs, Tabs and Lists
HIT3328 - Chapter0701 - Dialogs, Tabs and Lists
Yhal Htet Aung
Ā 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
Ā 

Semelhante a HIT3328 - Chapter04 - Complex Interactions (20)

Android Architecture Components
Android Architecture ComponentsAndroid Architecture Components
Android Architecture Components
Ā 
OLAP in Data Warehouse
OLAP in Data WarehouseOLAP in Data Warehouse
OLAP in Data Warehouse
Ā 
Belfast JUG 23-10-2013
Belfast JUG 23-10-2013Belfast JUG 23-10-2013
Belfast JUG 23-10-2013
Ā 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
Ā 
Cesar Valiente "Unidirectional architecture on Android with Kotlin"
Cesar Valiente "Unidirectional architecture on Android with Kotlin"Cesar Valiente "Unidirectional architecture on Android with Kotlin"
Cesar Valiente "Unidirectional architecture on Android with Kotlin"
Ā 
SenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay Platonov
SenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay PlatonovSenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay Platonov
SenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay Platonov
Ā 
Enterprise Software Architecture styles
Enterprise Software Architecture stylesEnterprise Software Architecture styles
Enterprise Software Architecture styles
Ā 
HIT3328 - Chapter0602 - Sketching Apps
HIT3328 - Chapter0602 - Sketching AppsHIT3328 - Chapter0602 - Sketching Apps
HIT3328 - Chapter0602 - Sketching Apps
Ā 
OpenML Tutorial ECMLPKDD 2015
OpenML Tutorial ECMLPKDD 2015OpenML Tutorial ECMLPKDD 2015
OpenML Tutorial ECMLPKDD 2015
Ā 
HIT3328 - Chapter0701 - Dialogs, Tabs and Lists
HIT3328 - Chapter0701 - Dialogs, Tabs and ListsHIT3328 - Chapter0701 - Dialogs, Tabs and Lists
HIT3328 - Chapter0701 - Dialogs, Tabs and Lists
Ā 
Finding sensor related energy black holes in smartphone applications
Finding sensor related energy black holes in smartphone applicationsFinding sensor related energy black holes in smartphone applications
Finding sensor related energy black holes in smartphone applications
Ā 
ML-Based Data-Driven Software Development with InfluxDB 2.0
ML-Based Data-Driven Software Development with InfluxDB 2.0ML-Based Data-Driven Software Development with InfluxDB 2.0
ML-Based Data-Driven Software Development with InfluxDB 2.0
Ā 
DataHub
DataHubDataHub
DataHub
Ā 
Runtime Behavior of JavaScript Programs
Runtime Behavior of JavaScript ProgramsRuntime Behavior of JavaScript Programs
Runtime Behavior of JavaScript Programs
Ā 
React, Flux, and Realtime RSVPs
React, Flux, and Realtime RSVPsReact, Flux, and Realtime RSVPs
React, Flux, and Realtime RSVPs
Ā 
Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014
Ā 
Functional reactive programming
Functional reactive programmingFunctional reactive programming
Functional reactive programming
Ā 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
Ā 
Building an Activity Feed with Cassandra
Building an Activity Feed with CassandraBuilding an Activity Feed with Cassandra
Building an Activity Feed with Cassandra
Ā 
Qualcomm Institute Winter IoT Program - Final Presentation
Qualcomm Institute Winter IoT Program - Final PresentationQualcomm Institute Winter IoT Program - Final Presentation
Qualcomm Institute Winter IoT Program - Final Presentation
Ā 

Mais de Yhal Htet Aung

HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and ListsHIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
Yhal Htet Aung
Ā 
HIT3328 - Chapter0702 - Navigation Flow and Design Approach
HIT3328 - Chapter0702 - Navigation Flow and Design ApproachHIT3328 - Chapter0702 - Navigation Flow and Design Approach
HIT3328 - Chapter0702 - Navigation Flow and Design Approach
Yhal Htet Aung
Ā 
HIT3328 - Chapter05 - Working with Forms
HIT3328 - Chapter05 - Working with FormsHIT3328 - Chapter05 - Working with Forms
HIT3328 - Chapter05 - Working with Forms
Yhal Htet Aung
Ā 
HIT3328 - Chapter02 - Foundation and Tools
HIT3328 - Chapter02 - Foundation and ToolsHIT3328 - Chapter02 - Foundation and Tools
HIT3328 - Chapter02 - Foundation and Tools
Yhal Htet Aung
Ā 

Mais de Yhal Htet Aung (16)

HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and ListsHIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
Ā 
HIT3328 - Chapter0702 - Navigation Flow and Design Approach
HIT3328 - Chapter0702 - Navigation Flow and Design ApproachHIT3328 - Chapter0702 - Navigation Flow and Design Approach
HIT3328 - Chapter0702 - Navigation Flow and Design Approach
Ā 
HIT3328 - Chapter05 - Working with Forms
HIT3328 - Chapter05 - Working with FormsHIT3328 - Chapter05 - Working with Forms
HIT3328 - Chapter05 - Working with Forms
Ā 
HIT3328 - Chapter02 - Foundation and Tools
HIT3328 - Chapter02 - Foundation and ToolsHIT3328 - Chapter02 - Foundation and Tools
HIT3328 - Chapter02 - Foundation and Tools
Ā 
CSC1100 - Chapter11 - Programming Languages and Program Development
CSC1100 - Chapter11 - Programming Languages and Program DevelopmentCSC1100 - Chapter11 - Programming Languages and Program Development
CSC1100 - Chapter11 - Programming Languages and Program Development
Ā 
CSC1100 - Chapter10 - Information System
CSC1100 - Chapter10 - Information SystemCSC1100 - Chapter10 - Information System
CSC1100 - Chapter10 - Information System
Ā 
CSC1100 - Chapter09 - Computer Security, Ethics and Privacy
CSC1100 - Chapter09 - Computer Security, Ethics and PrivacyCSC1100 - Chapter09 - Computer Security, Ethics and Privacy
CSC1100 - Chapter09 - Computer Security, Ethics and Privacy
Ā 
CSC1100 - Chapter08 - Database Management
CSC1100 - Chapter08 - Database ManagementCSC1100 - Chapter08 - Database Management
CSC1100 - Chapter08 - Database Management
Ā 
CSC1100 - Chapter07 - Communications & Networks
CSC1100 - Chapter07 - Communications & NetworksCSC1100 - Chapter07 - Communications & Networks
CSC1100 - Chapter07 - Communications & Networks
Ā 
CSC1100 - Chapter06 - Operating System & Utility Programs
CSC1100 - Chapter06 - Operating System & Utility ProgramsCSC1100 - Chapter06 - Operating System & Utility Programs
CSC1100 - Chapter06 - Operating System & Utility Programs
Ā 
CSC1100 - Chapter05 - Storage
CSC1100 - Chapter05 - StorageCSC1100 - Chapter05 - Storage
CSC1100 - Chapter05 - Storage
Ā 
CSC1100 - Chapter04 - Output
CSC1100 - Chapter04 - OutputCSC1100 - Chapter04 - Output
CSC1100 - Chapter04 - Output
Ā 
CSC1100 - Chapter03 - Input
CSC1100 - Chapter03 - InputCSC1100 - Chapter03 - Input
CSC1100 - Chapter03 - Input
Ā 
CSC1100 - Chapter02 - Components of the System Unit
CSC1100 - Chapter02 - Components of the System UnitCSC1100 - Chapter02 - Components of the System Unit
CSC1100 - Chapter02 - Components of the System Unit
Ā 
CSC1100 - Chapter01 - Overview of Using Computers
CSC1100 - Chapter01 - Overview of Using ComputersCSC1100 - Chapter01 - Overview of Using Computers
CSC1100 - Chapter01 - Overview of Using Computers
Ā 
CSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow ChartsCSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow Charts
Ā 

ƚltimo

Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...
Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...
Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...
amitlee9823
Ā 
infant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptxinfant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptx
suhanimunjal27
Ā 
Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
amitlee9823
Ā 
Verified Trusted Call Girls AdugodišŸ’˜ 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls AdugodišŸ’˜ 9352852248  Good Looking standard Profil...Verified Trusted Call Girls AdugodišŸ’˜ 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls AdugodišŸ’˜ 9352852248 Good Looking standard Profil...
kumaririma588
Ā 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptx
janettecruzeiro1
Ā 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
TusharBahuguna2
Ā 
young call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Serviceyoung call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
amitlee9823
Ā 
B. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdfB. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdf
University of Wisconsin-Milwaukee
Ā 
CALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun service
CALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun serviceCALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun service
CALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun service
anilsa9823
Ā 
Call Girls in Kalkaji Delhi 8264348440 call girls ā¤ļø
Call Girls in Kalkaji Delhi 8264348440 call girls ā¤ļøCall Girls in Kalkaji Delhi 8264348440 call girls ā¤ļø
Call Girls in Kalkaji Delhi 8264348440 call girls ā¤ļø
soniya singh
Ā 
RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...
amitlee9823
Ā 

ƚltimo (20)

Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...
Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...
Brookefield Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore...
Ā 
infant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptxinfant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptx
Ā 
Call Girls Service Mukherjee Nagar @9999965857 Delhi šŸ«¦ No Advance VVIP šŸŽ SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi šŸ«¦ No Advance  VVIP šŸŽ SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi šŸ«¦ No Advance  VVIP šŸŽ SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi šŸ«¦ No Advance VVIP šŸŽ SER...
Ā 
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Ā 
Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Basapura ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Ā 
Verified Trusted Call Girls AdugodišŸ’˜ 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls AdugodišŸ’˜ 9352852248  Good Looking standard Profil...Verified Trusted Call Girls AdugodišŸ’˜ 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls AdugodišŸ’˜ 9352852248 Good Looking standard Profil...
Ā 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptx
Ā 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
Ā 
Top Rated Pune Call Girls Koregaon Park āŸŸ 6297143586 āŸŸ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park āŸŸ 6297143586 āŸŸ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park āŸŸ 6297143586 āŸŸ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park āŸŸ 6297143586 āŸŸ Call Me For Genuine S...
Ā 
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
Ā 
young call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Serviceyoung call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Vivek ViharšŸ” 9953056974 šŸ” Delhi escort Service
Ā 
call girls in Vasundhra (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”...
call girls in Vasundhra (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”...call girls in Vasundhra (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”...
call girls in Vasundhra (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”...
Ā 
Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Escorts Service Nagavara ā˜Ž 7737669865ā˜Ž Book Your One night Stand (Bangalore)
Ā 
B. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdfB. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdf
Ā 
Pastel Portfolio _ by Slidesgo.pptx. Xxx
Pastel Portfolio _ by Slidesgo.pptx. XxxPastel Portfolio _ by Slidesgo.pptx. Xxx
Pastel Portfolio _ by Slidesgo.pptx. Xxx
Ā 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
Ā 
CALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun service
CALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun serviceCALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun service
CALL ON āž„8923113531 šŸ”Call Girls Aminabad Lucknow best Night Fun service
Ā 
Call Girls in Kalkaji Delhi 8264348440 call girls ā¤ļø
Call Girls in Kalkaji Delhi 8264348440 call girls ā¤ļøCall Girls in Kalkaji Delhi 8264348440 call girls ā¤ļø
Call Girls in Kalkaji Delhi 8264348440 call girls ā¤ļø
Ā 
RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bang...
Ā 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
Ā 

HIT3328 - Chapter04 - Complex Interactions

  • 1. HIT3328 / HIT8328 Software Development for Mobile Devices Dr. Rajesh Vasa, 2011 Twitter: @rvasa Blog: http://rvasa.blogspot.com 1 Lecture 04 Complex Interactions
  • 2. R. Vasa, 20112 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (using Global Variables) ā€¢Application Manifest File ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 3. R. Vasa, 20113 Android Device User Interaction Menu HomeBack
  • 4. R. Vasa, 20114 Android App. is made of Activities Activity View Group Views (Layout)
  • 5. R. Vasa, 20115 User Interface (generally) Built in XMLActivity View Group (Layout) Activity Class (Java) Layout Definition (main.xml) PresentatioPresentatio nn FunctionaliFunctionali tyty
  • 6. R. Vasa, 20116 The Android Way - Convention not Config. ā€¢Source code (src) ā€¢Generated code (gen) ā€¢Resources (res) ā€¢Images (@drawable) ā€¢Layout of app (layout) ā€¢Constants/Strings (@strings) Conventions to Follow
  • 7. R. Vasa, 20117 Portrait and Landscape Layouts Conventions to Follow
  • 8. R. Vasa, 20118 Provide Resources @Multiple Resolutions High Low Medium Conventions to Follow
  • 9. R. Vasa, 20119 View Identifiers @+id TAG creates new identifiers Conventions to Follow
  • 10. R. Vasa, 201110 UI Interaction Handling Pattern ā€¢Component.setOn......Listener ( handler ) ā€¢E.g. button.setOnClickListener ā€¢Handler is an anonymous inner class ā€¢On...Listener handler = new On....Listener() {}
  • 11. R. Vasa, 201111 Android Activity Life Cycle onCreate is called when Activity Starts Activity is re-started when orientatio n changes
  • 12. R. Vasa, 201112 We Retrieve State On Creation State retrieval done here onSaveInstanceState( ) is called from this state (Save Saved here)
  • 13. R. Vasa, 201113 Bundle stores simple state information BundleBundle putString(key, value) putDouble(key, value) putInt(key, value) putStringArray(k ey, value[]) It is a Key, Value store system (like a Hash Table or a Hash Map) Code Snippet: state.putString("inputTemperature", inputTemp); Code Snippet: state.putString("inputTemperature", inputTemp);
  • 14. R. Vasa, 201114 Working with Resources off.png Layout XML File Via Java Code on.png
  • 15. R. Vasa, 201115 Short Problem 1 - Passing Data ā€¢Context: In Android -- Apps are made of Activities. So, each Screen is a ā€œnewā€ Activity ā€¢ We want to pass data between Activities. ā€¢ But, Activity construction is managed by the Dalvik runtime. That is, cannot pass data into constructor. ā€¢What would you prefer to do? ā€¢ Store shared data in global variables available to ALL Activities. ā€¢ Move all data to a separate data layer. ā€¢ Send primitive data bundles between
  • 16. R. Vasa, 201116 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (using Global Variables) ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 17. R. Vasa, 201117 Wiring up Activities -- Typical Use Case Select Back Contact List Activity Contact Details
  • 18. R. Vasa, 201118 Wiring up Activities -- Typical Use Case Select Contact List Activity Contact Details We re-use this activity with different data Select
  • 19. R. Vasa, 201119 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing options ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (using Global Variables) ā€¢Passing Data Demo (using Intents)
  • 20. R. Vasa, 201120 Data Passing Option - Global Variables ā€¢We can use Global Variables ... but, ā€¢Widely accepted as a ā€œriskyā€ choice ā€¢A few global variables are used in many large systems (e.g. Linux Kernel Source Code) ā€¢Risk manageable in ā€˜smallā€™ programs ā€¢Good thread @ StackOverflow http://goo.gl/EouH3 ā€¢Constant values as globals is ok (e.g. R.java) ā€¢Key Issue (to manage): How many objects
  • 21. R. Vasa, 201121 Data Passing Option - Data Layer ā€¢We can store all data in a DBMS and access it via a ā€œdata layerā€ ā€¢Good idea when dealing with large / complex blocks of data ā€¢Overkill if we only need to store a few values ā€¢The data store can be ā€œin-memoryā€, ā€œon-diskā€, and/or ā€œon remote serverā€
  • 22. R. Vasa, 201122 Data Passing Option - Bundles ā€¢We can put data into a bundle and pass this across using a ā€œmessaging frameworkā€ ā€¢Simple (once you understand the messaging framework architecture) ā€¢Persistence is not managed (like DBMS)
  • 23. R. Vasa, 201123 Data Passing Option - iOS Only!! ā€¢You can pass data directly to methods in another screen (UIViewController) ā€¢UIViewController is approx. similar to Activity ā€¢This option is not possible in Android -- this was a ā€œdesign intentā€ (design side-effect?)
  • 24. R. Vasa, 201124 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (using Global Variables) ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 25. R. Vasa, 201125 iOS Apps. are directly managed by O/S UIAppDelegateUIAppDelegate UIViewController-UIViewController- AA UIViewController-UIViewController- BB UIViewController-UIViewController- CC UIAppDelegate has Life CycleView Controllers are managed by the App internally Image Source: Apple Inc. Life Cycle => Managed by Operating System
  • 26. R. Vasa, 201126 Android Activities are Managed by O/S Activity-AActivity-A Activity-CActivity-C Activity-BActivity-B ApplicatiApplicati onon Activities have a parent application Activity has Life CycleApplication is NOT managed directly by the O/SLife Cycle => Managed by Operating System
  • 27. R. Vasa, 201127 A Key Design Different (iOS Vs Android) Activity-AActivity-A Activity-CActivity-C Activity-BActivity-B UIAppDelegateUIAppDelegate UIViewController-UIViewController- AA UIViewController-UIViewController- BB UIViewController-UIViewController- CC ApplicatiApplicati onon UIAppDelegate has Life Cycle Activities have a parent application Activity has Life CycleApplication is NOT managed directly by the O/SLife Cycle => Managed by Operating System View Controllers are managed by the App internally
  • 28. R. Vasa, 201128 Activity Life Cycle Design Choice.... ā€¢Android developers decided to give Activity a life cycle (rather than the application) ā€¢This makes each Activity similar to a separate program ā€¢Hence, data passing is restricted to: ā€¢Global Variables (stored in Application object) ā€¢Data bundles passed via async. messages ā€¢Data stored externally in files or DBMS
  • 29. R. Vasa, 201129 Short Problem 2 - Activity Design Choice ā€¢Unlike iOS ViewControllers, Activities have been modelled to be (almost) like independent programs ā€¢What is the likely rationale for such a choice? ā€¢What would be the benefits?
  • 30. R. Vasa, 201130 Only One Activity is Active/Running ā€¢Only one Activity can be in the ā€˜foregroundā€™ ā€¢When Activity-A calls Activity-B ā€¢Activity-B will be visible to the user (foreground) ā€¢Activity-A is paused (background)
  • 31. R. Vasa, 201131 Activities are Stacked in Android ā€¢All created activities are placed on a Stack ā€¢Activities ā€˜poppedā€™ when ā€˜Back Buttonā€™ is pressed Activity-AActivity-A Foreground/Acti ve If only one activity is on the Activity Stack then ā€œbackā€ button exits it
  • 32. R. Vasa, 201132 Activities are Stacked in Android ā€¢All current activities are placed on a Stack ā€¢Newly started activities come into foreground Activity-AActivity-A Activity-BActivity-B Foreground/Acti ve starts Background/ Paused Back button will pop top most activity from stack
  • 33. R. Vasa, 201133 Activities are Stacked in Android ā€¢As additional activities are started, older activities go into background ā€¢All activities are placed on Activity Stack Activity-AActivity-A Activity-BActivity-B Activity-CActivity-CForeground/Acti ve starts starts Background/Pause d
  • 34. R. Vasa, 201134 Short Problem 3 - Activity Stacking ā€¢Consider the following situation, Activity-AActivity-A Activity-BActivity-B Activity-CActivity-C starts starts Activity-AActivity-A starts Are these activities the same object? Ponder the interaction design implications ..... Will Back Button Exit the App?
  • 35. R. Vasa, 201135 Lets get our feet wet
  • 36. R. Vasa, 201136 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (using Global Variables) ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 37. R. Vasa, 201137 Demo 1 - Life Cycle of an Android App. ā€¢Walk-through of code provided along with lecture handout. ā€¢We can see the states by adding a little bit of logging code to a few call-backs
  • 38. R. Vasa, 201138 Life-Cycle Demo onCreate, onStart, onResume etc. are from the Activity class
  • 39. R. Vasa, 201139 Life-Cycle Demo (Watching State)
  • 40. R. Vasa, 201140 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (Global Variables) ā€¢Application Manifest File ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 41. R. Vasa, 201141 Demo 2 - Passing Data
  • 42. R. Vasa, 201142 Before data passing -- a quick recap ā€¢This app. makes use of nested layouts ā€¢We can also make it look a bit nicer using weights
  • 43. R. Vasa, 201143 Anatomy of the App. (Nested Layout) Linear Layout TextView ImageView Linear Layout Button (Fruit) Button (Vegetable) Button (Drink)
  • 44. R. Vasa, 201144 A Weighty Problem Spot the difference in layout How achieved? android:layout_weight=ā€1ā€ for all buttons in the layout
  • 45. R. Vasa, 201145 Layout Weights are Handy If all buttons are given the same weight, then they will be of same size
  • 46. R. Vasa, 201146 Demo 2 - Passing Data Activity - FoodMain Activity - FoodView Data Passed: Name (ā€œFruitā€) Image (fruit.png)
  • 47. R. Vasa, 201147 Passing Data with Globals ā€¢All Activities have a parent Application object ā€¢We can store data in this Application object Activity-AActivity-A Activity-CActivity-C Activity-BActivity-B ApplicatiApplicati onon Activities have a parent application We need to extend the Application class to do this
  • 48. R. Vasa, 201148 What Creates/Manages Application? ā€¢Application is created and managed by the Android runtime ā€¢There is one Application object created by default ā€¢We can extend the ā€œApplication Classā€ and make our own ā€¢But, we need to tell the Runtime about this Application object via the Manifest XML file
  • 49. R. Vasa, 201149 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (Global Variables) ā€¢Application Manifest File ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 50. R. Vasa, 201150 Manifest contains Application Metadata ā€¢ Android runtime creates the Application object ā€¢ Application metadata is provided in the Manifest XML Manifest XML file is part of the project Auto-generated by Eclipse IDE
  • 51. R. Vasa, 201151 Manifest XML - What is it? Manifest informs Runtime about the App.Manifest informs Runtime about the App.
  • 52. R. Vasa, 201152 Manifest XML - Contents Application Name
  • 53. R. Vasa, 201153 Manifest XML - Contains Activity Names Activity Name(s)
  • 54. R. Vasa, 201154 Manifest XML - Refers to Icons Launcher Icon
  • 55. R. Vasa, 201155 Manifest XML - Refers to the App. Name Application Label
  • 56. R. Vasa, 201156 Passing Data with Globals ā€¢All Activities have a parent Application object ā€¢We can store data in this Application object FoodApplicatiFoodApplicati onon ApplicatiApplicati onon We need to extend the Application class to do this extends
  • 57. R. Vasa, 201157 Global Vars. can be in the Application FoodApplicatiFoodApplicati onon ApplicatiApplicati onon extends
  • 58. R. Vasa, 201158 Activities and Globals in Application ā€¢Activities can access data from the Application object We can also get to these variables from any Activi (declared in the Manifest XML file) We can also get to these variables from any Activit (declared in the Manifest XML file)
  • 59. R. Vasa, 201159 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (Global Variables) ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 60. R. Vasa, 201160 Demo 2 - Passing Data using Intents Activity - FoodMain Activity - FoodView Data Passed: Name (ā€œFruitā€) Image (fruit.png)
  • 61. R. Vasa, 201161 Wiring up the Buttons (Another Way) Buttons support onClick in the layout XML Buttons support onClick in the layout XML
  • 62. R. Vasa, 201162 Storing Data in a Bundle
  • 63. R. Vasa, 201163 Sending an Async. Message Android uses an asynchronous messaging model (known as Intents) to send messages between Activities Android uses an asynchronous messaging model (known as Intents) to send messages between Activities
  • 64. R. Vasa, 201164 Sending an Async. Message Setup Message and Store Data in the Message Setup Message and Store Data in the Message
  • 65. R. Vasa, 201165 Sending an Async. Message Class that is sending the Intent (message) Class that is sending the Intent (message)
  • 66. R. Vasa, 201166 Sending an Async. Message Class that will receive the Intent (message) Class that will receive the Intent (message) Class that is sending the Intent (message) Class that is sending the Intent (message)
  • 67. R. Vasa, 201167 Sending an Async. Message Send the Message to the Activity (Transmit) Send the Message to the Activity (Transmit)
  • 68. R. Vasa, 201168 Message Receiving Retrieve data from the message Retrieve data from the message
  • 69. R. Vasa, 201169 Intent Messages are Asynchronous ā€¢The intent system is completely asynchronous -- similar to e-mail ā€¢That is, ā€¢The receiver will get the message only if they request to see intents via getIntent() method ā€¢All transmitted messages are placed on a ā€˜Service Queueā€™
  • 70. R. Vasa, 201170 Complex Domain Models ā€¢Where do you hold a complex domain model?(E.g. we have 4-5 classes in a domain model) ā€¢We can hold a reference to the domain model objects in the Application ā€¢This is fine if there are only a few objects ā€¢Unlike Activity, Application is only terminated if device runs low on memory ā€¢If the data size is larger -- then best to use the sqlite database
  • 71. R. Vasa, 201171 Lecture Overview ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (Global Variables) ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 72. R. Vasa, 201172 Controlling Input Data Type ā€¢A common task on forms is to restrict users to certain data types ā€¢Email Address ā€¢Decimal Numbers ā€¢Positive Integers ā€¢Alpha Numeric ā€¢On mobile devices -- development platforms offer a simple way to control the keyboard type
  • 73. R. Vasa, 201173 Controlling Input Type (Android) ā€¢Android has a large number of options ā€¢You can merge them to create more complex input types textUri textEmailAddress textPassword textPersonName number numberSigned numberDecimal numberPassword textUri textEmailAddress textPassword textPersonName number numberSigned numberDecimal numberPassword android:inputTypeandroid:inputType
  • 74. R. Vasa, 201174 Input Type - Example http://developer.android.com/reference/android/widget/TextView.html#attr_andro id:inputType More info. at the following URL
  • 75. R. Vasa, 201175 Lecture Recap ā€¢Recap (previous 2 weeks) ā€¢Passing Data between Activities ā€¢Data passing methods ā€¢Activity Design Choice ā€¢Activity Life Cycle ā€¢Passing Data Demo (Global Variables) ā€¢Passing Data Demo (using Intents) ā€¢Controlling Input Type
  • 76. R. Vasa, 201176 Whatā€™s next? ā€¢Usability Principles - Mobile Form Design ā€¢Using Dialogs ā€¢Returning data back from an Activity ā€¢Simple File I/O ā€¢More complex layouts ā€¢Exploring a few more widgets