introduc)on*to*android* - inesc-id

24
Introduc)on to Android Mobile and Ubiquitous Compu)ng MEIC/MERC 2015/16 Nuno Santos

Upload: others

Post on 27-Nov-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduc)on*to*Android* - INESC-ID

Introduc)on*to*Android*

Mobile*and*Ubiquitous*Compu)ng*

MEIC/MERC*2015/16*

*

Nuno*Santos*

Page 2: Introduc)on*to*Android* - INESC-ID

1.#SOME#CONTEXT#

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 3: Introduc)on*to*Android* - INESC-ID

What*Is*Android?*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

“Android*delivers*a*complete*set*of*soIware*for*

mobile*devices:*an*opera)ng*system,*middleware*

and*key*mobile*applica)ons.”*

*

!!"h$p://android.com/about/"

Page 4: Introduc)on*to*Android* - INESC-ID

Why*Look*Into*Android?*

•  Android*is*the*world’s*most*popular*mobile*plaSorm*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Source:"h$p://www.idc.com/prodserv/smartphone!os!market!share.jsp""

Page 5: Introduc)on*to*Android* - INESC-ID

The*History*of*Android*

•  2003*V*Android*Inc.*founded*by*Andy*Rubin*•  Build*”…smarter*mobile*devices,*more*aware*of*its*owner's*loca)on*and*preferences"*

•  2005*V*Google*acquired*Android*Inc.*

•  2007*–*Crea)on*of*the*Open*Handset*Alliance*•  A*consor)um*of*companies*whose*goal*is*to*develop*open*standards*for*mobile*devices*

•  Members*include*Texas*Instruments,*Broadcom*Corpora)on,*Google,*HTC,*Intel…*

•  2008*–*Android*1.0*is*released*

•  2008*–*14*new*members*joined;*to*date,*more*than*47*organiza)ons*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 6: Introduc)on*to*Android* - INESC-ID

Android*Releases*

•  1.0*V*Released*September,*2008*

•  1.1*V*Released*February,*2009*

•  1.5*(Cupcake)*V*Released*April,*2009*

•  1.6*(Donut)*V*Released*September,*2009*

•  2.0*/*2.1*(Eclair)*V*Released*October,*2009*(2.0)*and*January,*2010*(2.1)*

•  2.2*(Froyo)*V*Released*May,*2010*

•  2.3*(Gingerbread)*V**Released*December,*2010*

•  3.0*(Honeycomb)*V*Released*February,*2011*

•  4.0*(Ice*Cream*Sandwich)*–*Released*October,*2011*

•  4.1*(Jelly*Bean)*–*Released*June,*2012*

•  …*

•  4.4*(Kit*Kat)*–*Released*September,*2013*

•  5.0*(Lollipop)*–*Released*October,*2014*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 7: Introduc)on*to*Android* - INESC-ID

2.#ANDROID#OVERVIEW#

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 8: Introduc)on*to*Android* - INESC-ID

Architecture*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 9: Introduc)on*to*Android* - INESC-ID

Noteworthy*Features*

•  JavaVbased*objectVoriented*applica)on*framework*

–  Apps*on*top*of*Java*core*libraries*running*on*a*Dalvik*virtual*machine*

•  HighlyVop)mized*Java*implementa)on*

–  Very*memoryV*and*performanceVefficient*

–  Highly*tuned*to*limita)ons*of*small*hardware*

*

•  Based*upon*a*modified*version*of*the*Linux*kernel*

•  Rich*development*environment*

–  Device*emulator,*tools*for*debugging,*profiling,*rich*IDE*integra)on*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 10: Introduc)on*to*Android* - INESC-ID

Security*and*Permissions*

•  Each*app*deployed*with*unique*user*and*group*ID*–  Each*applica)on*file*is*private*–  Sharing*must*be*done*explicitly*

•  Applica)ons*sandboxed*in*separate*VMs*

•  Principle*of*least*privilege*–  Applica)ons*must*declare*the*permissions*they*need*

–  The*system*prompts*the*user*for*consent*at*install*)me*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 11: Introduc)on*to*Android* - INESC-ID

3.#ANATOMY#OF#ANDROID#APPS#

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 12: Introduc)on*to*Android* - INESC-ID

Component*Example*

•  Ac<vi<es:*are*like*the*pages*in*a*website*–  Provide*an*interface*for*users*to*interact*with*the*app*and*take*an*ac)on*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Ac<vity#A* Ac<vity#B*

Page 13: Introduc)on*to*Android* - INESC-ID

Views*

•  Views:*UI*elements,*hierarchically*organized*

–  Two*types:*layouts,*and*widgets"

Mobile*and*Ubiquitous*Compu)ng*2015/16*

E.g.,*buqon*

E.g.,*linear*layout*

Page 14: Introduc)on*to*Android* - INESC-ID

Components*

•  There*are*four*different*types*of*applica)on*components*

–  Each*type*has*different*purpose*and*a*dis)nct*lifecycle*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

E.g.,*play*music*in*

background*

E.g.,*manage*user’s*

contact*informa)on*

E.g.,*show*list*of*

emails*

E.g.,*take*ac)on*if*

baqery*low*

Page 15: Introduc)on*to*Android* - INESC-ID

Intents*

•  Messages*that*enable*communica)on*across*components*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 16: Introduc)on*to*Android* - INESC-ID

Applica)on*Internals*

*

*

*

*

*

*

*

*

*

*

Android*Applica)on*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Ac)vity*A*

Service*A*

Ac)vity*B*

Components#Modules*

View*A* View*B* View*3*

Views#UI*elements*(e.g.,*buqon)*

Intent*A* Intent*C*

Intent*B*

Intent*D*

Intents#Messages*

Page 17: Introduc)on*to*Android* - INESC-ID

4.#APPLICATION#DEVELOPMENT#

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 18: Introduc)on*to*Android* - INESC-ID

Development*Tools*

•  Android*SoIware*Development*Kit*(SDK)*

–  Tools*to*create,*compile,*and*package*apps*

–  Device*emulator*

–  Tools*to*create*Android*Virtual*Devices*(AVDs)*–  Android*Debug*Bridge*(ADB)*tool*

•  Android*Studio*–  Full*blown*IDE*based*on*IntelliJ*–  Create,*compile,*debug*and*deploy*Android*applica)ons*

–  Create*and*start*AVDs*–  Specialized*edi)on*of*resource*files*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 19: Introduc)on*to*Android* - INESC-ID

Android*Studio*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 20: Introduc)on*to*Android* - INESC-ID

Development*Process*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

manifest

resources

source code

.xml

images, etc. aapt tool

.apk

3. Package

1. Edit

.class

R.java

java compiler

dx tool

.dex

2. Compile

adb tool

4. Deploy

Page 21: Introduc)on*to*Android* - INESC-ID

Manifest*

•  AndroidManifest.xml*defines*the*skeleton*of*an*applica)on*

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 22: Introduc)on*to*Android* - INESC-ID

Resources*

•  Include*images*and*certain*XML*configura)on*files*

–  e.g.,*res/layout/acBvity_main.xml"

•  A*reference*to*a*new*resource*is*automa)cally*created*in*R.java"!

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 23: Introduc)on*to*Android* - INESC-ID

Source*Code*•  Source*code*implements*the*app*components*

–  E.g.,*src/com/example/myfirstapp/MainAcBvity.java"

Mobile*and*Ubiquitous*Compu)ng*2015/16*

Page 24: Introduc)on*to*Android* - INESC-ID

Useful*Links*

•  Android*developers:*hqp://developer.android.com*

–  Training:**hqp://developer.android.com/training/index.html*

*

–  API*Guides:**hqp://developer.android.com/guide/components/index.html*

*

–  Reference**hqp://developer.android.com/reference/packages.html*

•  Remember,*Google*is*your*friend*!*

*

Mobile*and*Ubiquitous*Compu)ng*2015/16*