You are on page 1of 14

Programming with Mobile

Applications
Chapter 2: Developing for Small Devices

In Chapter 2, You Learn to


Describe the architecture of each
platform
Summarize the similarities and
differences between platforms
Explain the life cycle of an app on
each platform
Compare life cycle features in each
platform
Programming with Mobile Applications

General Platform
Architecture

Application layer
Core libraries
Operating system
Hardware

Figure 2-1 General platform


architecture
Programming with Mobile Applications

The Android Platform


Figure 2-2 The Android architecture

Programming with Mobile Applications

The iOS Platform

Figure 2-3 The iOS architecture

Programming with Mobile Applications

The Windows Phone 7


Platform
Figure 2-4 The
Windows Phone 7 architecture

Programming with Mobile Applications

App Lifecycle
Apps have a well-defined life cycle
Encompasses the events of being
started, running, and being
destroyed
Each platform has specific code for
these events
The OS calls the code you supply for
each life cycle event automatically
Programming with Mobile Applications

Android Components
Component

Functionality

Activity

Represents a single screen with a user


interface

Service

Runs in the background to perform longrunning operations

Content Provider

Manages a shared set of application data

Broadcast Receiver

Responds to systemwide broadcasts

Programming with Mobile Applications

Android Activity Lifecycle


Figure 2-5 Life cycle events in the Activity
component

Android Service Lifecycle


Figure 2-6 Life cycle events in the Service
component

Programming with Mobile Applications

10

Android Content Provider and


Broadcast Receiver Lifecycles
Content Providers store and retrieve
data no lifecycle events
Broadcast Receivers listen for
systemwide broadcasts
Low battery
Incoming message

Valid within scope of onReceive()


method
Programming with Mobile Applications

11

iOS App Lifecycle


Figure 2-7 The iOS app life cycle

Programming with Mobile Applications

12

Windows Phone 7 App


Figure 2-12Lifecycle
The Windows Phone 7 app
life cycle

Programming with Mobile Applications

13

Comparing Lifecycles
Event

Android

iOS

Windows Phone 7

Start

onCreate()

application:
DidFinishLaunchingWithOp
tions:

Application_Launching(
),
InitializeComponent()

Running

onStart(),
applicationDidBecomeActi
onResume() ve:

Deactivate
d

onStop(),
onPause()

applicationWillResignActiv
e:,
applicationDidEnterBackgr
ound:

Application_Deactivate
d(),
NavigatedFrom()

Activated

onResume() applicationWillEnterForegr
ound:

Application_Activated()
,
NavigatedTo()

Closing
onDestroy()
applicationWillTerminate:
Programming with
Mobile Applications

Application_Closing() 14

You might also like