You are on page 1of 15

EC312:

OOP
Module6

Appl
i
cat
ionSt
ruct
ure-
Andr
oidMani
fest
.xml
,uses-
per
missi
on&uses-
sdk
Ev
eryapppr
ojectmusthav
eanAndr
oidMani
fest
.xmlf
il
e(wi
thpr
eci
sel
ythatname)att
he
r
ootoft
hepr
ojectsour
ceset
.Themani
festf
il
edescr
ibesessent
iali
nfor
mat
ionabouty
ourappt
o
t
heAndr
oidbui
l
dtool
s,t
heAndr
oidoper
ati
ngsy
stem,
andGoogl
ePl
ay.
Amongmanyot
hert
hings,
themani
festf
il
eisr
equi
redt
odecl
aret
hef
oll
owi
ng:
Theapp'
spackagename,whi
chusual
l
ymat
chesy
ourcode'
snamespace.TheAndr
oidbui
l
d
t
ool
suset
hist
o det
ermi
net
hel
ocat
ionofcodeent
it
ieswhenbui
l
ding y
ourpr
oject
.When
packagi
ngt
heapp,t
hebui
l
dtool
srepl
acet
hisv
aluewi
tht
heappl
i
cat
ionI
Dfr
om t
heGr
adl
ebui
l
d
f
il
es,whi
chi
susedast
heuni
queappi
dent
if
ieront
hesy
stem andonGoogl
ePl
ay.Readmor
e
aboutt
hepackagenameandappI
D.
Thecomponent
soft
heapp,whi
chi
ncl
udeal
lact
ivi
ti
es,ser
vices,br
oadcastr
ecei
ver
s,and
cont
entpr
ovi
der
s.Eachcomponentmustdef
inebasi
cpr
oper
ti
essuchast
henameofi
tsKot
li
nor
Jav
acl
ass.I
tcanal
sodecl
arecapabi
l
iti
essuchaswhi
chdev
iceconf
igur
ati
onsi
tcanhandl
e,and
i
ntentf
il
ter
sthatdescr
ibehowt
hecomponentcanbest
art
ed.Readmor
eaboutappcomponent
s.
Theper
missi
onst
hatt
heappneedsi
nor
dert
oaccesspr

E S . ot
I N
ect
edpar
tsoft
hesy
stem orot
her

NOT
apps.I
tal
sodecl
aresanyper
missi
onst
hatot
herappsmusthav
eift
heywantt
oaccesscont
ent

KTU
f
rom t
hisapp.Readmor
eaboutper
missi
ons.
Thehar
dwar
eandsof
twar
efeat
urest
heappr
equi
res,whi
chaf
fect
swhi
chdev
icescani
nst
all
t
heappf
rom Googl
ePl
ay.Readmor
eaboutdev
icecompat
ibi
l
ity
.
Foreachappcomponentt
haty
oucr
eat
einy
ourapp,y
oumustdecl
areacor
respondi
ngXML
el
ementi
nthemani
festf
il
e:
<act
ivi
ty>f
oreachsubcl
assofAct
ivi
ty.
<ser
vice>f
oreachsubcl
assofSer
vice.
<r
ecei
ver
>foreachsubcl
assofBr
oadcast
Recei
ver
.
<pr
ovi
der
>foreachsubcl
assofCont
ent
Prov
ider
.
I
fyousubcl
assanyoft
hesecomponent
swi
thoutdecl
ari
ngi
tint
hemani
festf
il
e,t
hesy
stem
cannotst
arti
t.
Thenameofy
oursubcl
assmustbespeci
fi
edwi
tht
henameat
tr
ibut
e,usi
ngt
hef
ullpackage
desi
gnat
ion.Forexampl
e,anAct
ivi
tysubcl
asscanbedecl
aredasf
oll
ows:
<mani
fest.
..>
  <appl
i
cat
ion.
..>
    <act
ivi
tyandr
oid:
name="
com.
exampl
e.my
app.
Mai
nAct
ivi
ty".
..>

Downloaded from Ktunotes.in


    </
act
ivi
ty>
  </
appl
i
cat
ion>
</
mani
fest
>
Themani
festf
il
eisal
sowher
eyoucandecl
arewhatt
ypesofhar
dwar
eorsof
twar
e
f
eat
uresy
ourappr
equi
res,andt
hus,whi
cht
ypesofdev
icesy
ourappi
scompat
ibl
ewi
th.Googl
e
Pl
aySt
oredoesnotal
l
ow y
ourappt
obei
nst
all
edondev
icest
hatdon'
tpr
ovi
det
hef
eat
uresor
sy
stem v
ersi
ont
haty
ourappr
equi
res.
Ther
ear
esev
eralmani
festt
agst
hatdef
inewhi
chdev
icesy
ourappi
scompat
ibl
ewi
th.The
f
oll
owi
ngar
ejustacoupl
eoft
hemostcommont
ags.
<uses-
feat
ure>
The<uses-
feat
ure>el
emental
l
owsy
out
odecl
arehar
dwar
eandsof
twar
efeat
uresy
ourappneeds.
The f
oll
owi
ng t
abl
e pr
ovi
des l
i
nks t
oref
erence document
sforal
lval
i
d el
ement
sint
he
Andr
oidMani
fest
.xml
fil
e.

<act
ion> Addsanact
iont
oani
ntentf
il
ter
.
<act
ivi
ty> Decl
aresanact
ivi
tycomponent
.
<act
ivi
ty-
ali
as> Decl
aresanal
i
asf
oranact
ivi
ty.
<appl
i
cat
ion> Thedecl
arat
ionoft
E
heappl
i
S
cat
i. I
on. N
<cat
egor
y>

KTU
Addsacat
egor
NOT
ynamet
oani
ntentf
il
ter
.

<dat
a> Addsadat
aspeci
fi
cat
iont
oani
ntentf
il
ter
.
Speci
fi
es t
he subset
s ofapp dat
athatt
he par
entcont
entpr
ovi
derhas
<gr
ant
-ur
i-
per
missi
on>
per
missi
ont
oaccess.

Speci
fi
est
het
ypesofi
ntent
sthatanact
ivi
ty,ser
vice,orbr
oadcastr
ecei
ver
<i
ntent
-f
il
ter
>
canr
espondt
o.
<mani
fest
> Ther
ootel
ementoft
heAndr
oidMani
fest
.xml
fil
e.
Aname-
val
uepai
rforani
tem ofaddi
ti
onal
,ar
bit
rar
ydat
athatcanbesuppl
i
ed
<met
a-dat
a>
t
othepar
entcomponent
.
Def
inest
hepat
handr
equi
redper
missi
onsf
oraspeci
fi
csubsetofdat
awi
thi
n
<pat
h-per
missi
on>
acont
entpr
ovi
der
.
Decl
aresasecur
it
yper
missi
ont
hatcanbeusedt
oli
mitaccesst
ospeci
fi
c
<per
missi
on>
component
sorf
eat
uresoft
hisorot
herappl
i
cat
ions.
<per
missi
on-
group> Decl
aresanamef
oral
ogi
cal
groupi
ngofr
elat
edper
missi
ons.

Downloaded from Ktunotes.in


<pr
ovi
der
> Decl
aresacont
entpr
ovi
dercomponent
.
<r
ecei
ver
> Decl
aresabr
oadcastr
ecei
vercomponent
.
<ser
vice> Decl
aresaser
vicecomponent
.
<suppor
ts-
gl-
text
ure> Decl
aresasi
ngl
eGLt
ext
urecompr
essi
onf
ormatt
hatt
heappsuppor
ts.
Decl
arest
hescr
eensi
zesy
ourappsuppor
tsandenabl
esscr
eencompat
ibi
l
ity
<suppor
ts-
scr
eens>
modef
orscr
eensl
argert
hanwhaty
ourappsuppor
ts.
<uses-
conf
igur
ati
on> I
ndi
cat
esspeci
fi
cinputf
eat
urest
heappl
i
cat
ionr
equi
res.
<uses-
feat
ure> Decl
aresasi
ngl
ehar
dwar
eorsof
twar
efeat
uret
hati
susedbyt
heappl
i
cat
ion.
<uses-
li
brar
y> Speci
fi
esashar
edl
i
brar
ythatt
heappl
i
cat
ionmustbel
i
nkedagai
nst
.
Speci
fi
esasy
stem per
missi
ont
hatt
heusermustgr
anti
nor
derf
ort
heappt
o
<uses-
per
missi
on>
oper
atecor
rect
ly.
<uses-
per
missi
on-
sdk-Speci
fi
est
hatanappwant
sapar
ti
cul
arper
missi
on,butonl
yift
heappi
s
23> i
nst
all
edonadev
icer
unni
ngAndr
oid6.
0(APIl
evel
23)orhi
gher
.
Let
syouexpr
essanappl
i
cat
ion'
scompat
ibi
l
itywi
thoneormor
ever
sionsof
<uses-
sdk>
t
heAndr
oidpl
atf
orm,
bymeansofanAPIl
evel
int
eger
.
Ex
ampl
emani
festf
il
e

E S . I N
NOT
TheXMLbel
owi
sasi
mpl
eexampl
eAndr
oidMani
fest
.xml
thatdecl
arest
woact
ivi
ti
esf
ort
heapp.
<?
xml
ver
<mani
f
sion="
est
1.
KTU
0"encodi
ng="
utf
-8"
?>

  xml
ns:
andr
oid="
htt
p:/
/schemas.
andr
oid.
com/
apk/
res/
andr
oid"
  andr
oid:
ver
sionCode="
1"
  andr
oid:
ver
sionName="
1.0"
  package="
com.
exampl
e.my
app"
>
  <!
--Bewar
ethatt
hesev
aluesar
eov
err
iddenbyt
hebui
l
d.gr
adl
efi
l
e--
>
  <uses-
sdkandr
oid:
minSdkVer
sion="
15"andr
oid:
tar
get
SdkVer
sion="
26"/
>
  <appl
i
cat
ion
    andr
oid:
all
owBackup="
tr
ue"
    andr
oid:
i
con="
@mi
pmap/
ic_
launcher
"
    andr
oid:
roundI
con="
@mi
pmap/
ic_
launcher
_round"
    andr
oid:
l
abel
="@st
ri
ng/
app_
name"
    andr
oid:
suppor
tsRt
l="
tr
ue"
    andr
oid:
theme="
@st
yle/
AppTheme"
>
    <!
--Thi
snamei
sresol
vedt
ocom.
exampl
e.my
app.
Mai
nAct
ivi
ty

Downloaded from Ktunotes.in


       
basedupont
hepackageat
tri
but
e--
>
    <act
ivi
tyandr
oid:
name="
.Mai
nAct
ivi
ty"
>
      <i
ntent
-f
il
ter
>
        <act
ionandr
oid:
name="
andr
oid.
int
ent
.act
ion.
MAI
N"/
>
        <cat
egor
yandr
oid:
name="
andr
oid.
int
ent
.cat
egor
y.LAUNCHER"/
>
      </
int
ent
-f
il
ter
>
    </
act
ivi
ty>
    <act
ivi
ty
      andr
oid:
name="
.Di
spl
ayMessageAct
ivi
ty"
      andr
oid:
par
ent
Act
ivi
tyName="
.Mai
nAct
ivi
ty"/
>
  </
appl
i
cat
ion>
</
mani
fest
>
Per
missi
ons/
Uses-
per
missi
on
Andr
oidappsmustr
equestper
missi
ont
oaccesssensi
ti
veuserdat
a(suchascont
act
sandSMS)
orcer
tai
n sy
stem f
eat
ures (
such as t
he camer
a and i
nter
netaccess)
.Each per
missi
on i
s
i
dent
if
iedbyauni
quel
abel
.Forexampl
e,anappt
hatneedst
osendSMSmessagesmusthav
ethe
f
oll
owi
ngl
i
nei
nthemani
fest
:
<mani
fest.
..>
E S . I N
  <uses-
  .
..
per
missi
onandr
oid:
name="

KTU
andr
NOT
oid.
per
missi
on.
SEND_
SMS"
/>

</
mani
fest
>
Begi
nni
ngwi
thAndr
oid6.
0(APIl
evel23)
,theusercanappr
oveorr
ejectsomeappper
misi
onsat
r
unt
ime.Butnomat
terwhi
chAndr
oidv
ersi
ony
ourappsuppor
ts,
youmustdecl
areal
lper
missi
on
r
equest
swi
tha<uses-
per
missi
on>el
ementi
nthemani
fest
.Ift
heper
missi
oni
sgr
ant
ed,t
heapp
i
sabl
etouset
hepr
otect
edf
eat
ures.I
fnot
,it
sat
tempt
stoaccesst
hosef
eat
uresf
ail
.
Yourapp can al
so pr
otecti
ts own component
s wi
th per
missi
ons.I
tcan use anyoft
he
per
missi
onst
hatar
edef
inedbyAndr
oid,
asl
i
stedi
nandr
oid.
Mani
fest
.per
missi
on,
oraper
missi
on
t
hat
'
sdecl
aredi
nanot
herapp.Yourappcanal
sodef
inei
tsownper
missi
ons.Anewper
missi
oni
s
decl
aredwi
tht
he<per
missi
on>el
ement
.
<Uses-
sdk>
Eachsuccessi
vepl
atf
ormv
ersi
onof
tenaddsnew API
snotav
ail
abl
eint
hepr
evi
ousv
ersi
on.To
i
ndi
cat
ethemi
nimum v
ersi
onwi
thwhi
chy
ourappi
scompat
ibl
e,y
ourmani
festmusti
ncl
udet
he
<uses-
sdk>t
agandi
tsmi
nSdkVer
sionat
tri
but
e.
Howev
er,bewar
ethatat
tri
but
esi
nthe<uses-
sdk>el
ementar
eov
err
iddenbycor
respondi
ng
pr
oper
ti
es i
nthe bui
l
d.gr
adl
efi
l
e.So i
fyou'
re usi
ng Andr
oid St
udi
o,y
ou mustspeci
fyt
he

Downloaded from Ktunotes.in


mi
nSdkVer
sionandt
arget
SdkVer
sionv
aluest
her
einst
ead:
andr
oid{
 def
aul
tConf
ig{
  appl
i
cat
ionI
d'com.
exampl
e.my
app'
  /
/Def
inest
hemi
nimum APIl
evel
requi
redt
orunt
heapp.
  mi
nSdkVer
sion15
  /
/Speci
fi
est
heAPIl
evel
usedt
otestt
heapp.
  t
arget
SdkVer
sion26
 }
}
Lay
out
s&Dr
awabl
eResour
ces
Thebasi
cbui
l
dingbl
ockf
oruseri
nter
facei
saVi
ewobj
ectwhi
chi
scr
eat
edf
rom
t
heVi
ewcl
ass.TheVi
ewGr
oupi
sasubcl
assofVi
ewandpr
ovi
desi
nvi
sibl
econt
ainer
.
Andr
oidLay
outTy
pes
1Li
nearLay
out
Li
near
Lay
outi
sav
iewgr
oupt
hatal
i
gnsal
lchi
l
dreni
nasi
ngl
edi
rect
ion,
ver
ti
cal
l
yorhor
izont
all
y.

E S . I N
KTU NOT
2Rel
ati
veLay
out
Rel
ati
veLay
outi
sav
iewgr
oupt
hatdi
spl
ayschi
l
dvi
ewsi
nrel
ati
veposi
ti
ons.

3Tabl
eLay
out
Tabl
eLay
outi
sav
iewt
hatgr
oupsv
iewsi
ntor
owsandcol
umns.

Downloaded from Ktunotes.in


4Absol
uteLay
out
Absol
uteLay
outenabl
esy
out
ospeci
fyt
heexactl
ocat
ionofi
tschi
l
dren.
5Fr
ameLay
out
TheFr
ameLay
outi
sapl
acehol
deronscr
eent
haty
oucanuset
odi
spl
ayasi
ngl
evi
ew.
6Li
stVi
ew
Li
stVi
ewi
sav
iewgr
oupt
hatdi
spl
aysal
i
stofscr
oll
abl
eit
ems.

7Gr
idVi
ew
E S . I N
Gr
idVi
Lay
ewi
saVi
outAt
tr
i
ewGr
but
es
oupt
hatdi

KTU
spl
aysi
temsi
NOT
nat
wo-
dimensi
onal
,scr
oll
abl
egr
id.

andr
oid:
i
d Thi
sist
heI
Dwhi
chuni
quel
yident
if
iest
hev
iew.
andr
oid:
l
ayout
_wi
dth Thi
sist
hewi
dthoft
hel
ayout
.
andr
oid:
l
ayout
_hei
ght Thi
sist
hehei
ghtoft
hel
ayout
andr
oid:
l
ayout
_mar
ginTop Thi
sist
heext
raspaceont
het
opsi
deoft
hel
ayout
.
andr
oid:
l
ayout
_mar
ginBot
tom Thi
sist
heext
raspaceont
hebot
tom si
deoft
hel
ayout
.
andr
oid:
l
ayout
_mar
ginLef
t Thi
sist
heext
raspaceont
hel
eftsi
deoft
hel
ayout
.
andr
oid:
l
ayout
_mar
ginRi
ght Thi
sist
heext
raspaceont
her
ightsi
deoft
hel
ayout
.
Andr
oidUICont
rol
s
1Text
View Thi
scont
rol
isusedt
odi
spl
ayt
extt
otheuser
.
2Edi
tText Edi
tTexti
sapr
e-def
inedsubcl
assofText
Viewt
hati
ncl
udesr
ichedi
ti
ng
capabi
l
iti
es.
3Aut
oCompl
eteText
View TheAut
oCompl
eteText
View i
sav
iew t
hati
ssi
mil
art
o Edi
tText
,
ex
ceptt
hati
tshowsal
i
stofcompl
eti
onsuggest
ionsaut
omat
ical
l
ywhi
l
etheuseri
sty
ping.
4But
ton Apush-
but
tont
hatcanbepr
essed,
orcl
i
cked,
byt
heusert
oper
for
m anact
ion.
5I
mageBut
ton Absol
uteLay
outenabl
esy
out
ospeci
fyt
heexactl
ocat
ionofi
tschi
l
dren.

Downloaded from Ktunotes.in


6Checkbox Anon/
offswi
tcht
hatcanbet
oggl
edbyt
heuser
.Youshoul
dusecheckboxes
whenpr
esent
inguser
swi
thagr
oupofsel
ect
abl
eopt
ionst
hatar
enotmut
ual
l
yexcl
usi
ve.
7Toggl
eBut
ton Anon/
offbut
tonwi
thal
i
ghti
ndi
cat
or.
8Radi
oBut
ton TheRadi
oBut
tonhast
wost
ates:
eit
hercheckedorunchecked.

9Radi
oGr
oup ARadi
oGr
oupi
susedt
ogr
oupt
oget
heroneormor
eRadi
oBut
tons.
10Pr
ogr
essBar ThePr
ogr
essBarv
iewpr
ovi
desv
isual
feedbackaboutsomeongoi
ng
t
asks,
suchaswheny
ouar
eper
for
mingat
aski
nthebackgr
ound.
Sampl
eCode
<Li
near
Lay
outxml
ns:
andr
oid="
htt
p:/
/schemas.
andr
oid.
com/
apk/
res/
andr
oid"
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="f
il
l_
par
ent
"
andr
oid:
ori
ent
ati
on="
ver
ti
cal
">
andr
oid:
text
="Thi
sisaText
View"/
>
<But
tonandr
oid:
i
d="
@+i
d/but
ton"
andr
oid:
l
ayout
_wi
dth="
wrap_
cont
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="Thi
sisaBut
ton"/
>
E S . I N
Opt
i
Av
mi
oi
zi
ngl
ayout
s
dunnecessar
KTU
ynest
ing NOT
Av
oidusi
ngt
oomanyv
iews
Av
oiddeepnest
ingofl
ayout
s
Dr
awabl
eResour
ces
Gr
aphi
cst
hatcanbedr
awnt
oscr
eenorwhi
chcanbeappl
i
edt
oanot
herXML.Ar
epl
acedi
nthe
i
ntot
her
es/
drawabl
efol
der
.
Ther
ear
esev
eral
dif
fer
entt
ypesofdr
awabl
es:
Bi
tmapFi
l
e
Abi
tmapgr
aphi
cfi
l
e(.
png,
.j
pg,
or.
gif
).Cr
eat
esaBi
tmapDr
awabl
e.
Ni
ne-
Pat
chFi
l
e
APNGf
il
ewi
thst
ret
chabl
eregi
onst
oal
l
owi
mager
esi
zi
ngbasedoncont
ent(
.9.
png)
.Cr
eat
esa
Ni
nePat
chDr
awabl
e.
Lay
erLi
st
ADr
awabl
ethatmanagesanar
rayofot
herDr
awabl
es.Thesear
edr
awni
nar
rayor
der
,sot
he
el
ementwi
tht
hel
argesti
ndexi
sbedr
awnont
op.Cr
eat
esaLay
erDr
awabl
e.
St
ateLi
st

Downloaded from Ktunotes.in


AnXMLf
il
ethatr
efer
encesdi
ff
erentbi
tmapgr
aphi
csf
ordi
ff
erentst
ates(
forexampl
e,t
ousea
di
ff
erenti
magewhenabut
toni
spr
essed)
.Cr
eat
esaSt
ateLi
stDr
awabl
e.
Lev
elLi
st
AnXMLf
il
ethatdef
inesadr
awabl
ethatmanagesanumberofal
ter
nat
eDr
awabl
es,each
assi
gnedamaxi
mum numer
ical
val
ue.Cr
eat
esaLev
elLi
stDr
awabl
e.
Tr
ansi
ti
onDr
awabl
e
AnXMLf
il
ethatdef
inesadr
awabl
ethatcancr
oss-
fadebet
weent
wodr
awabl
eresour
ces.Cr
eat
es
aTr
ansi
ti
onDr
awabl
e.
Emul
ator
-Andr
oidVi
rt
ual
Dev
ice
AnAndr
oidemul
atori
sanAndr
oidVi
rt
ual
Dev
ice(
AVD)t
hatr
epr
esent
saspeci
fi
cAndr
oid
dev
ice.YoucanuseanAndr
oidemul
atorasat
argetpl
atf
ormt
orunandt
esty
ourAndr
oid
appl
i
cat
ionsony
ourPC.Usi
ngAndr
oidemul
ator
sisopt
ional
.Iti
sawel
l
-knownper
for
mance
i
ssuet
hatAndr
oidemul
ator
sar
eext
remel
ysl
owandt
hus,
thedev
eloper
sgener
all
yuseaphy
sical
dev
icet
otestt
heappl
i
cat
ion.Auseoft
heEmul
atori
sthatt
heappl
i
cat
ioncanbet
est
edi
nvar
ious
scr
eensi
zesandconf
igur
ati
ons.
Cr
eat
ingAVD
I
fyouwantt
oemul
atear
eal
dev
ice,
fir
stcr
ateanAVDwi
tht
hesamedev
iceconf
igur
ati
onsasr
eal
dev
ice,
thenl
auncht
hisAVDf
rom AVDmanager
.
E S . I N
Changi
Usual
l
ngOr
ient
ybydef
at
aul
i
on
twheny
oul
KTU
auncht
heemulNOT
ator
,it
sor
ient
ati
oni
sver
ti
cal
,buty
oucanchangei
t
or
ient
ati
onbypr
essi
ngCt
rl
+F11keyf
rom key
boar
d.
Emul
atorCommands.
Apar
tfr
om j
ustor
ient
ati
oncommands,t
her
ear
eot
herv
eryusef
ulcommandsofemul
atort
hat
y
oushoul
dkeepi
nmi
ndwhi
l
eusi
ngemul
ator
.Theyar
eli
stedbel
ow−
Sr
.No Command&descr
ipt
ion
HHome
1
SShi
ft
stomai
nscr
een
F
2 TToggl
escont
extsensi
ti
ve
mMenu
F
3
BBr
ingoutcal
ll
og
F
4
EEndcal
l
5F

Downloaded from Ktunotes.in


SSear
ch
F
6
TToggl
etr
ackbal
lmode
F
7
Ppowerbut
ton
F
8
TToggl
edat
anet
wor
k
CCt
rl
+F5
9
RBr
ingVol
umeup
CCt
rl+F6
10
RBr
ingVolumedown
Emul
ator-Sendi
ngSMS
Youcanemul
atesendi
ngSMSt
oyouremul
ator
.Ther
ear
etwoway
stodot
hat
.Youcandot
hat
f
rom DDMSwhi
chcanbef
oundi
nAndr
oidst
udi
o,orf
rom Tel
net
.
Emul
ator-Maki
ngCal
l
Youcaneasi
l
ymakephonecal
l
stoy
ouremul
atorusi
ngt
elentcl
i
ent
.Youneedt
oconnectt
oyour
emul
atorf
rom t
elnet
.Iti
sdi
scussedi
nthesendi
ngsmst
opi
cabov
e.
Af
tert
haty
ouwi
l
lty
pet
hiscommandi
nthet
elentwi
E
ndowt
S . I N
omakeacal
l
.It
ssy
ntaxi
sgi
venbel
ow

gsm cal
l1234 KTU NOT
Emul
ator-Tr
ansf
err
ingf
il
es
Youcaneasi
l
ytr
ansf
erf
il
esi
ntot
heemul
atorandv
icev
ersa.I
nor
dert
odot
hat
,youneedt
o
sel
ectt
heDDMSut
il
it
yinAndr
oidst
udi
o.Af
tert
hatsel
ectt
hef
il
eexpl
orert
ab.
UIDesi
gn,
Sty
les&Themes
Fordesi
gni
nggr
eatAndr
oidappl
i
cat
ionsy
oushoul
dfol
l
ow t
hef
oll
owi
ngt
hemeswhi
char
e
descr
ibedi
ndet
ail
.
 Desi
gnf
ort
ouch
 Showonl
ywhati
sneeded
 Don’
taskf
orper
missi
onf
oracer
tai
nact
ionbutal
l
owt
heusert
oundohi
sact
ion
 Onl
yint
err
upt
,ifi
tisi
mpor
tant
 Keepmessagesbr
ief
,usepi
ctur
es
 Nev
erl
osey
ouruser
sdat
a
 Al
l
owuser
stomakei
mpor
tantt
hingsf
ast
 I
fisl
ookst
hesame,
itshoul
dactt
hesame
 Hel
puser
smakedeci
sions,
butl
ett
hem hav
ethef
inal
say

Downloaded from Ktunotes.in


Gener
aldesi
gnbestpr
act
ices:
-
Desi
gnf
orper
for
mance
Desi
gnf
orr
esponsi
veness
Desi
gnf
ori
nst
antdat
a
Desi
gnf
oropt
imi
zedbat
ter
yli
fe

Desi
gnf
oref
fi
ci
entnet
wor
kaccess
A st
ylei
sacol
l
ect
ionofat
tri
but
est
hatspeci
fyt
heappear
ancef
orasi
ngl
eVi
ew.Ast
ylecan
speci
fyat
tr
ibut
essuchasf
ontcol
or,
fontsi
ze,
backgr
oundcol
or,
andmuchmor
e.
At
hemei
sat
ypeofst
ylet
hat
'
sappl
i
edt
oanent
ir
eapp,act
ivi
ty,orv
iew hi
erar
chy
,notj
ustan
i
ndi
vi
dual
view.
Tocr
eat
eanewst
yleort
heme,
openy
ourpr
oject
'
sres/
val
ues/
sty
l xmlf
es. il
e.Foreachst
yley
ouwant
t
ocr
eat
e,f
oll
owt
hesest
eps:
1. Adda<st
yle>el
ementwi
thanamet
hatuni
quel
yident
if
iest
hest
yle.
2. Addan<i
tem>el
ementf
oreachst
yleat
tri
but
eyouwantt
odef
ine.
Thenamei
neachi
tem speci
fi
esanat
tri
but
eyouwoul
dot
her
wiseuseasanXMLat
tr
ibut
einy
our
l
ayout
.Thev
aluei
nthe<i
tem>el
ementi
sthev
aluef
ort
hatat
tr
ibut
e.
Ex
ampl
e:

E S . I N
NOT
<?
xml
ver
sion="
1.0"encodi
ng="
utf
-8"
?>

KTU
<r
esour
ces>
  <st
ylename="
GreenTex
t"par
ent
="Text
Appear
ance.
AppCompat
">
    <i
tem name="
andr
oid:
text
Col
or"
>#00FF00</
it
em>
  </
sty
le>
</
resour
ces>
Ex
tendandcust
omi
zeast
yle
Whencr
eat
ingy
ourownst
yles,
youshoul
dal
way
sext
endanexi
sti
ngst
ylef
rom t
hef
ramewor
kor
suppor
tli
brar
ysot
haty
oumai
ntai
ncompat
ibi
l
itywi
thpl
atf
orm UIst
yles.Toext
endast
yle,
speci
fyt
hest
yley
ouwantt
oext
endwi
tht
hepar
entat
tr
ibut
e.Youcant
henov
err
idet
hei
nher
it
ed
st
yleat
tri
but
esandaddnewones.
Forexampl
e,y
oucani
nher
itt
heAndr
oidpl
atf
orm'
sdef
aul
ttextappear
anceandmodi
fyi
tas
f
oll
ows:
<st
ylename="
GreenText
"par
ent
="@andr
oid:
sty
le/
Text
Appear
ance"
>
  <i
tem name="
andr
oid:
text
Col
or"
>#00FF00</
it
em>
</
sty
le>
Appl
yast
yleasat
heme
Youcancr
eat
eat
hemet
hesamewayy
oucr
eat
est
yles.Thedi
ff
erencei
show y
ouappl
yit
:

Downloaded from Ktunotes.in


i
nst
ead ofappl
yi
ng a st
yle wi
tht
he st
yleat
tri
but
e on a v
iew,y
ou appl
ya t
heme wi
tht
he
andr
oid:
themeat
tri
but
eonei
thert
he<appl
i
cat
ion>t
agoran<act
ivi
ty>t
agi
ntheAndr
oidMani
fest
.xmlf
il
e.
Forexampl
e,her
e'showt
oappl
ytheAndr
oidSuppor
tLi
brar
y'
smat
eri
aldesi
gn"
dar
k"t
hemet
othe
whol
eapp:
<mani
fest.
..>
  <appl
i
cat
ionandr
oid:
theme="
@st
yle/
Theme.
AppCompat
"..
.>
  </
appl
i
cat
ion>
</
mani
fest
>
Cust
omi
zet
hedef
aul
ttheme
Wheny
oucr
eat
eapr
ojectwi
thAndr
oidSt
udi
o,i
tappl
i
esamat
eri
aldesi
gnt
hemet
oyourappby
def
aul
t,asdef
inedi
nyourpr
oject
'
sst
yl xmlf
es. il
e.
Forexampl
e,y
ourst
yles.
xml
fil
eshoul
dlooksi
mil
art
othi
s:
<st
ylename="
AppTheme"par
ent
="Theme.
AppCompat
.Li
ght
.Dar
kAct
ionBar
">
  <!
--Cust
omi
zey
ourt
hemeher
e.-
->
  <i
tem name="
col
orPr
imar
y">@col
or/
col
orPr
imar
y</
it
em>
  <i
tem name="
col
orPr
imar
yDar
k">@col
or/
col
orPr
imar
yDar
k</
it
em>
  <i
tem name="
col
orAccent
">@col
or/
col
orAccent
</i
tem>
</
sty
le>
E S . I N
Cont
entpr
ovi
der
s-SQLi
Acont
tepr
entpr
ov
ogr
i
ammi

KTU
ng
NOT
dermanagesaccesst
oacent
ralr
eposi
tor
yofdat
a.Youi
mpl
ementa
pr
ovi
derasoneormor
ecl
assesi
nanAndr
oidappl
i
cat
ion,
alongwi
thel
ement
sint
hemani
festf
il
e.
Oneofy
ourcl
assesi
mpl
ement
sasubcl
assCont
entPr
ovi
der
,whi
chi
sthei
nter
facebet
weeny
our
pr
ovi
derandot
herappl
i
cat
ions.Al
thoughcont
entpr
ovi
der
sar
emeantt
omakedat
aav
ail
abl
eto
ot
herappl
i
cat
ions,y
oumayofcour
sehav
eact
ivi
ti
esi
nyourappl
i
cat
iont
hatal
l
ow t
heusert
o
quer
yandmodi
fyt
hedat
amanagedbyy
ourpr
ovi
der
.
Fol
l
owt
hesest
epst
obui
l
dyourpr
ovi
der
:
 Desi
gnt
her
awst
oragef
ory
ourdat
a.Acont
entpr
ovi
derof
fer
sdat
aint
woway
s:
o Fi
l
edat
a
o "
Str
uct
ured"dat
a
 Def
ineaconcr
etei
mpl
ement
ati
onoft
heCont
entPr
ovi
dercl
assandi
tsr
equi
redmet
hods.
Thi
scl
assi
sthei
nter
facebet
weeny
ourdat
aandt
her
estoft
heAndr
oidsy
stem.
 Def
inet
hepr
ovi
der
'saut
hor
it
yst
ri
ng,i
tscont
entURI
s,andcol
umnnames.I
fyouwantt
he
pr
ovi
der
'sappl
i
cat
iont
ohandl
eint
ent
s,al
sodef
inei
ntentact
ions,
ext
rasdat
a,andf
lags.Al
so
def
inet
heper
missi
onst
haty
ouwi
l
lrequi
ref
orappl
i
cat
ionst
hatwantt
oaccessy
ourdat
a.
 Add ot
her opt
ional pi
eces, such as sampl
e dat
a or an i
mpl
ement
ati
on of

Downloaded from Ktunotes.in


Abst
ract
Thr
eadedSy
ncAdapt
ert
hatcansy
nchr
oni
zedat
abet
weent
hepr
ovi
derandcl
oud-
baseddat
a.
I
mpl
ement
ingt
heCont
ent
Prov
iderCl
ass
TheCont
ent
Prov
ideri
nst
ancemanagesaccesst
oast
ruct
uredsetofdat
abyhandl
i
ngr
equest
s
f
rom ot
herappl
i
cat
ions.Al
lfor
msofaccessev
ent
ual
l
ycal
lCont
ent
Resol
ver
,whi
cht
hencal
l
sa
concr
etemet
hodofCont
ent
Prov
idert
ogetaccess.
Requi
redmet
hods
quer
y()
Ret
ri
evedat
afr
om y
ourpr
ovi
der
.Uset
hear
gument
stosel
ectt
het
abl
etoquer
y,t
her
owsand
col
umnst
oret
urn,
andt
hesor
tor
deroft
her
esul
t.Ret
urnt
hedat
aasaCur
sorobj
ect
.
i
nser
t()
I
nser
tanewr
owi
ntoy
ourpr
ovi
der
.Uset
hear
gument
stosel
ectt
hedest
inat
iont
abl
eandt
oget
t
hecol
umnv
aluest
ouse.Ret
urnacont
entURIf
ort
henewl
y-
inser
tedr
ow.
updat
e()
Updat
eexi
sti
ngr
owsi
nyourpr
ovi
der
.Uset
hear
gument
stosel
ectt
het
abl
eandr
owst
oupdat
e
andt
ogett
heupdat
edcol
umnv
alues.Ret
urnt
henumberofr
owsupdat
ed.
del
ete(
)
Del
eter
owsf
rom y
ourpr
ovi
der
.Uset
hear
gument
st
E S .
osel
I N
ectt
het
abl
eandt
her
owst
odel
ete.
Ret
ur
get
Ty
nt
henumberofr
pe(
)
owsdel
et

KTU
ed.
NOT
Ret
urnt
heMI
MEt
ypecor
respondi
ngt
oacont
entURI
.Thi
smet
hodi
sdescr
ibedi
nmor
edet
aili
n
t
hesect
ionI
mpl
ement
ingCont
entPr
ovi
derMI
METy
pes.
onCr
eat
e()
I
nit
ial
i
zey
ourpr
ovi
der
.TheAndr
oidsy
stem cal
l
sthi
smet
hodi
mmedi
atel
yaf
teri
tcr
eat
esy
our
pr
ovi
der
.Not
icet
haty
ourpr
ovi
deri
snotcr
eat
edunt
ilaCont
ent
Resol
verobj
ectt
ri
est
oaccessi
t.
SQl
i
tedat
abasei
sanopen-
sour
cel
i
ghtwei
ghtr
elat
ional
dat
abase.
SQLi
tedat
abasei
susedt
ost
oredat
ainst
ruct
uredf
ormat
.
Byst
ruct
ureddat
awemeanschema,
tabl
es"
rowsandcol
umns"
,indexes,
andsoon.
SQl
i
tedat
abasecomesembeddedwi
thi
nAndr
oidoper
ati
ngsy
stem.
SQLi
tedat
abasei
susedbyAndr
oidappl
i
cat
ionst
ost
oredat
ainpr
ivat
edat
abase.
Andr
oidpr
ovi
desast
andar
dAPIt
oint
eractwi
thSQLi
tedat
abasef
rom y
ourAndr
oidappl
i
cat
ion.
Usi
ngt
hest
andar
dAPIy
oucancr
eat
eadat
abaseandt
abl
esandper
for
m CRUD"
creat
e,r
ead,
updat
e,del
ete"oper
ati
ons.
Dat
abasecr
eat
edbyanappl
i
cat
ionwi
l
lbeaccessi
blebynamet
oanycl
assoft
hatappl
i
cat
ion,
butnotout
sidet
heappl
i
cat
ion.

Downloaded from Ktunotes.in


Dat
abasef
il
esf
oranappl
i
cat
ioncanbef
oundunder/
dat
a/dat
a/[
app-
package]
/dat
abases/
[db-
name]
Tomakey
ourdat
abasedat
aaccessi
blet
oot
herappl
i
cat
ionsuseCont
entPr
ovi
der
.
TheAndr
oidf
ramewor
kusesaconceptcal
l
edcont
entpr
ovi
der
stoenabl
eappl
i
cat
ionst
oshar
eanduse
dat
aacr
osst
hepl
atf
orm.
St
ep1:
Creat
ingt
heDat
abaseCl
ass
Fi
rst
,youmustcr
eat
etheappl
i
cat
ion’
sunder
lyi
ngSQLi
tedat
abase.Begi
nbycr
eat
inganewcl
ass
namedTut
List
Dat
abaset
hatext
endsf
rom SQLi
teOpenHel
per
.
St
ep2:
Def
ini
ngt
heDat
abaseSchema
Ouri
nit
ial
art
icl
edat
ahadj
ustt
wodat
afi
elds:
ati
tl
eandal
i
nk.Ther
e’snor
easonnott
okeept
his
sor
tofst
ruct
urei
nourSQLi
tedat
abase.We'
l
lneedamandat
ory_
idf
iel
d,t
oo,
whi
chact
sasa
uni
quei
dent
if
ierf
oreachr
ecor
d.
St
ep3:
Creat
ingt
heDat
abase
Dat
abasecr
eat
ionshoul
dnowbef
air
lyst
rai
ght
for
war
d.Wi
thi
ntheonCr
eat
e()met
hod,
simpl
y
ex
ecut
etheDB_
SCHEMAst
ri
ngasSQLt
ocr
eat
ethet
abl
eyoudef
inedi
nthepr
evi
ousst
ep:
@Ov
err
ide
publ
i
cvoi
donCr
eat
e(SQLi
teDat
abasedb){
db.
execSQL(
DB_
SCHEMA)
;

E S . I N
NOT
}

KTU
St
ep4:
Upgr
adi
ngt
heDat
abase
Si
ncet
hedat
abasei
sbr
andnew,
wehav
enoupgr
adepol
i
cyweneedt
ofol
l
ow.Ther
efor
e,we'
l
ljustdr
op
t
het
abl
eandr
ecr
eat
eiti
fanupgr
ader
equesti
smade.
St
ep5:
Creat
ingt
heCont
entPr
ovi
derCl
ass
Nowt
haty
ourappl
i
cat
ionhasaf
unct
ional
dat
abase,
youcant
urny
ourat
tent
iont
oimpl
ement
ingacont
ent
pr
ovi
dert
oaccess,
expose,
andmanaget
hear
ti
cledat
ast
oredt
her
e.Begi
nbycr
eat
inganewcl
assnamed
Tut
li
stPr
ovi
derwhi
chext
endst
heCont
ent
Prov
idercl
ass.Gi
vei
tapr
ivat
ememberv
ari
abl
etohol
dan
i
nst
anceofaTut
List
Dat
abase.I
nst
ant
iat
ethedat
abasei
ntheonCr
eat
e()met
hod:
St
ep6:
Prepar
ingHel
perConst
ant
sandt
heMat
cher
Howev
er,
thi
sident
if
icat
iondoesn'
tact
ual
l
yhappenbymagi
c.I
nst
ead,
cont
entpr
ovi
dercl
assesgener
all
y
pr
ovi
desomepubl
i
cconst
ant
sthatcanbeusedbyappst
oident
if
ythedat
atheywantt
oquer
y.I
nsi
det
he
cont
entpr
ovi
der
,somehel
pisav
ail
abl
efordet
ermi
ningwhatki
ndofURIi
sbei
ngpassedi
n.
St
ep7:
Regi
ster
ingt
heCont
entPr
ovi
der
Li
keanAct
ivi
tycl
ass,
aCont
entPr
ovi
dermustbepr
oper
lyr
egi
ster
edi
ntheAndr
oidMani
festf
il
e.
St
ep8:
Updat
ingt
heLi
stVi
ew
Wi
tht
hecont
entpr
ovi
deri
mpl
ement
ati
oncompl
ete,
let
'
supdat
etheappl
i
cat
iont
ousei
t!Wi
thi
n
Tut
List
Fragmentcl
ass,
updat
etheonCr
eat
e()met
hodt
ouset
henewcont
entpr
ovi
der

Downloaded from Ktunotes.in


St
ep9:
Fini
shi
ngt
heCont
entPr
ovi
der
Al
thought
heappl
i
cat
iondoesnoty
etuset
hei
nser
t()
,updat
e()
,get
Type(
),ordel
ete(
)met
hods,
itwi
l
lint
he
f
utur
ewheny
oust
artgr
abbi
ng“
li
ve”t
utor
ial
dat
afr
om ar
emot
esour
ce.Thei
mpl
ement
ati
onofeachof
t
hesemet
hodsf
oll
owsapat
ter
nsi
mil
art
othatoft
hequer
y()met
hod.

E S . I N
KTU NOT

Downloaded from Ktunotes.in

You might also like