Android Architecture CS 4720 Mobile Application Development CS - - PowerPoint PPT Presentation

android architecture
SMART_READER_LITE
LIVE PREVIEW

Android Architecture CS 4720 Mobile Application Development CS - - PowerPoint PPT Presentation

Android Architecture CS 4720 Mobile Application Development CS 4720 The Basics In general, all apps are written in Java (this is not always the case as there are third-party conversion tools) A compiled Android app is an .apk


slide-1
SLIDE 1

CS 4720

Android Architecture

CS 4720 – Mobile Application Development

slide-2
SLIDE 2

CS 4720

The Basics

  • In general, all apps are written in Java (this is

not always the case as there are third-party conversion tools)

  • A compiled Android app is an .apk
  • Android apps must be digitally signed in some

way to execute

  • This digital signature can be a debug certificate

that comes default with any installation

2

slide-3
SLIDE 3

CS 4720

The Basics

  • Android is a multi-user Linux OS
  • Each app is given it’s own user id when it is

installed

  • Every app is given it’s own “sandbox” where

the files are set to permissions only for that app to read and write

  • Every app runs in it’s own VM (i.e. code runs in

isolation from other apps)

  • Every app is a separate Linux process

3

slide-4
SLIDE 4

CS 4720

The Basics

  • It is possible for apps to share data with other

apps

– 1. Two apps can have the same Linux user id (and thus share resources) if and only if they are signed by the same digital certificate – 2. Apps can setup data sharing privileges through the permissions xml system in each manifest

4

slide-5
SLIDE 5

CS 4720

The Android Architecture

5

slide-6
SLIDE 6

CS 4720

Main Components

  • Activities – represent a single screen with a UI
  • Services – represents a process running in the

background

  • Content Provider – a link back to the data
  • Broadcast Receiver – listens for system-wide

messages to respond to

  • Application – a set of Activities that make up a

cohesive unit

  • Intent – a message to be passed

6

slide-7
SLIDE 7

CS 4720

Activity

  • Conceptually, an Activity is a single screen of

your application

  • In other words, an App really is a collection of

related Activities

  • Consider each Activity both a screen and a

feature

  • Apps can activate Activities in other Apps

7

slide-8
SLIDE 8

CS 4720

Service

  • A Service is a component that runs in the

background to perform long-running

  • perations
  • A Service has no UI
  • Examples of Services:

– Playing music in background – Gathering GPS data – Downloading a data set from the server

8

slide-9
SLIDE 9

CS 4720

Content Provider

  • A Content Provider manages a shared set of

app data

  • This shared set of data could be a file, an

SQLite DB, a remote link to a web service, etc.

  • Apps can query a Content Provider for data if

they have permission

  • For example, your App could query the

Contacts DB for a set of email addresses

  • Content Providers can also be private

9

slide-10
SLIDE 10

CS 4720

Broadcast Receivers

  • A Broadcast Receiver responds to system-wide

announcements (which are manifested as Intents)

  • System status information is delivered this way

(i.e. device turned on side, screen off, low battery, phone call incoming, etc.)

  • Broadcast Receivers typically don’t have a UI,

but could have a status bar icon

10

slide-11
SLIDE 11

CS 4720

Connected Apps

  • Due to the component nature of Apps (made

up of Activities, Services, etc.), it is easy to build features of your App using existing system components

  • For example, if your App needs to take a

picture, you can query the Camera Activity to handle that request and return the resulting image

  • This is handled through Intents

11

slide-12
SLIDE 12

CS 4720

Intent

  • An Intent is a message that requests an action

from another component of the system

  • This includes the “please start up your App”

Intent that the system sends when a user clicks

  • n your App icon

12

slide-13
SLIDE 13

CS 4720

Tying it all Together

  • If an App is made up of all these disparate

parts, what holds them all together?

  • The AndroidManifest.xml file!

– Sets up all permissions the user has to agree to (i.e. Internet, GPS, contacts, etc.) – Declares the API level of the App – Requests hardware features needed – Needed libraries – Which Activities are part of this App

13

slide-14
SLIDE 14

CS 4720

What about the other stuff?

  • Typically referred to as “assets,” anything that

isn’t code is placed in the res/ folder

  • Music
  • Images
  • Some static data files

14

slide-15
SLIDE 15

CS 4720

Where’s the UI?

  • The User Interface for an Android App is

defined in the layout xml files

  • Each layout xml file should correspond to an

Activity

15

slide-16
SLIDE 16

CS 4720

The App Lifecycle

16

slide-17
SLIDE 17

CS 4720

Looking at Example Code

  • Android examples are available in GitHub
  • These examples are easily downloaded directly

from Android Studio

17