Escolar Documentos
Profissional Documentos
Cultura Documentos
Mobile Computing
Activities
Lecture#05
2
Lecture Contents
vApplication Architecture
vApplication Types
vActivities
vServices
v
3
Application Architecture
vActivity Manager
ØControls Activity Life Cycle
ØControls Activity Stack
vViews
ØUI elements
ØComponents to be displayed on Activities
ØViewGroup
vNotification Manager
vContent Providers
vResource Manager
vAndroid Libraries (API)
4
Application Types
vForeground Applications
(Games, Interactive Applications etc)
v Background Applications
(Anti-virus, Screening applications, SMS Auto-responders)
vIntermittent Application
(Media Player, Download Manager etc)
vDesktop Widget
(Clock, Temperature, Converter Apps)
v
5
Phone Development
vHardware Imposed Design Consideration
vBe Efficient
vExpect Limited Capacity
vSmall Screen Size
vLow Speed, High Latency
6
Activity
vSingle focusable object (User interaction)
vUse setContentView() to set UI elements
vMostly full screen (can be a floating window as well
or even embedded inside other activity)
vActivity can be start from other activity:
üstartActivity()
üstartActivityForResult()
vManaged by an activity stack
vNew activity is placed on the top of the stack and
becomes the running activity (previous activity
always remains below it in the stack, and will not
come to the foreground again until the new activity
exits)
8
Activity Creation
11
Activity States
vActive/Running
a.Top of activity stack
b.Activity in the foreground of the screen (Visible)
c.In Focus
d.May be receiving input OR showing results
e.Android will put all efforts to keep it alive (killing
other processes/activities)
vVisible but Lost Focus
a.It is still visible (that is, a new non-full-sized or
transparent activity has focus on top of your
activity)
b.It is paused (Not in focus)
c.A paused activity is completely alive (it maintains all
state and member information and remains
attached to the window manager)
13
Activity States
vNot Visible but Alive
a.If an activity is completely obscured by another
activity, it is stopped
b.Still retains all state and member information,
c.It is no longer visible to the user
vStopped
a.System can drop the activity from memory by
either asking it to finish, or simply killing its
process
b.When displayed again to the user, must be
completely restarted and restored to its
previous state
•
14 Activity Life Cycle
15
17
Activity Types
vActivity
vListActivity
vMapActivity
vExpandableListActivity
vTabActivity
20
Launch a Screen
Intent activityStart = new Intent(currentActivity,
intendedActivity);
startActivity(activityStart);
21
intendedActivity);
startActivityForResult(activityStart);
22
stats.putString(“position”, “Manager");
finish();
23
Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == 0) {
Bundle extras = data.getExtras();
}
}
24
Launch a Website
Intent browserIntent = new
Intent("android.intent.action.VIEW",
Uri.parse("http://www.google.com"));
startActivity(browserIntent);