Android Application Development MANUAL JNTUH
Android Application Development MANUAL JNTUH
Android Application Development MANUAL JNTUH
THYDERABAD
Col
l
egeofEngi
neer
ingf
orWomen
Raj
i
vGandhi
Nagar
,Bachupal
l
y,Hy
der
abad-
90
Depar
tmentofComput
erSci
ence&Engi
neer
ing
ANDROI
DAPPLI
CATI
ONDEVELOPMENTLAB
I
VYear–ISemest
er
(
R16Regul
ati
on)
I
NSTI
TUTEVI
SION&MI
SSI
ON
VI
SION
To emergeasthebestamongt heinst
it
utesoftechnol
ogyandr
esear
chi
nthecount
ry
dedi
cat
edtothecauseofpr
omot
ingqual
it
ytechni
cal
educat
ion.
MI
SSI
ON
Empowermentofwomenengineer
sandt
echnocr
atswi
themphasi
sonacademi
cex
cel
l
ence,
l
if
eski
ll
sandhumanvalues.
DEPARTMENTVI
SION&MI
SSI
ON
VI
SION
Devel
opwomenast echnocr
ats,
resear
cher
sandent
repr
eneur
sint
hef
iel
dofcomput
er
sci
enceandengi
neeri
ng.
MI
SSI
ON
M1:Toimpar
tqual
it
yeducationi
nComput
erSci
enceandEngi
neer
ingbymeansofl
ear
ning
t
echni
quesandval
ue-addedcour
ses.
M2:Toincul
cat
eprofessi
onalexcel
l
enceandresear
chcult
urebyencour
agi
ngpr
oject
sin
cut
ti
ng-
edgetechnol
ogiesthr
oughindust
ryi
nter
acti
ons.
M3:
Tobui
l
dleader
shi
pski
l
ls,
ethi
cal
val
uesandt
eamwor
kamongt
hest
udent
s.
M4:Tostr
engt
hent
hecoll
aborat
ionofdepart
mentandi
ndust
ryt
hroughi
nter
nshi
ps,
mentor
shi
psandpr
ofessi
onal
bodyactiv
iti
es.
Pr
ogr
am Educat
ional
Obj
ect
ives(
PEOs)
PEO-
1:Adaptemer
gingt
echnol
ogi
est
ocont
ri
but
etot
het
echni
cal
innov
ati
onsf
ort
he
pr
ogr
essi
vedev
elopmenti
nthei
rrespect
ivef
iel
ds.
PEO-
2:Pr
oduct
ivel
yengagei
nmul
ti
disci
pli
nar
yresear
char
easbyappl
yi
ngt
hebasi
cpr
inci
ples
ofengi
neer
ingsci
ences.
PEO-
3:Demonst
rat
est
rongt
echni
cal
ski
l
lst
obr
ingoutnov
eldesi
gns/
product
stoaddr
ess
soci
al&env
ironment
ali
ssues.
PEO-
4:Exhi
bitpr
ofessi
onal
att
it
ude,
teamwor
kandpr
act
icecodeofet
hics.
Pr
ogr
am Speci
fi
cObj
ect
ives(
PSOs)
PSO1:
Abil
it
ytoappl
ylear
nedski
l
lstobui
ldopt
imi
zedsoluti
onspert
aini
ngt
oComput
er&
Communi
cati
onSyst
ems,DataPr
ocessi
ngandArt
if
ici
alI
ntel
li
gence.
PSO2Employst
andardst
rat
egi
esandpr
act
icesi
npr
ojectdev
elopmentusi
ngFOSS(
Free
OpenSour
ceSof
tware)
Pr
ogr
am Out
comes
PO1.Engi
neer
ing knowl
edge:Appl
ytheknowl
edgeofmat
hemat
ics,sci
ence,engi
neer
ing
f
undament
als,and an engi
neer
ing speci
ali
zat
ion t
othe sol
uti
on ofcompl
exengi
neer
ing
pr
obl
ems.
PO2.Pr
obl
em anal
ysi
s:I
dent
if
y,f
ormul
ate,r
evi
ew r
esear
chl
i
ter
atur
e,andanal
yzecompl
ex
engi
neer
ing pr
obl
ems r
eachi
ng subst
ant
iat
ed concl
usi
ons usi
ng f
ir
st pr
inci
ples of
mat
hemat
ics,
nat
ural
sci
ences,
andengi
neer
ingsci
ences.
PO3.Desi
gn/
dev
elopmentofsol
uti
ons:Desi
gnsol
uti
onsf
orcompl
exengi
neer
ingpr
obl
ems
anddesi
gnsy
stem component
sorpr
ocessest
hatmeett
hespeci
fi
edneedswi
thappr
opr
iat
e
consi
der
ati
onf
ort
hepubl
i
cheal
thandsaf
ety
,andt
hecul
tur
al,soci
etal
,andenv
ironment
al
consi
der
ati
ons.
PO4.Conducti
nvest
igat
ions ofcompl
ex pr
obl
ems:Use r
esear
ch-
based knowl
edge and
r
esear
chmet
hodsi
ncl
udi
ngdesi
gnofexper
iment
s,anal
ysi
sandi
nter
pret
ati
onofdat
a,and
sy
nthesi
soft
hei
nfor
mat
iont
opr
ovi
dev
ali
dconcl
usi
ons.
PO5.Moder
ntoolusage:Cr
eat
e,sel
ect
,andappl
yappr
opr
iat
etechni
ques,r
esour
ces,and
moder
nengi
neer
ingandI
Ttool
sincl
udi
ngpr
edi
cti
onandmodel
i
ngt
ocompl
exengi
neer
ing
act
ivi
ti
eswi
thanunder
standi
ngoft
hel
i
mit
ati
ons.
PO6.Theengi
neerandsoci
ety
:Appl
yreasoni
ngi
nfor
medbyt
hecont
ext
ualknowl
edget
o
assesssoci
etal
,heal
th,saf
ety
,legalandcul
tur
ali
ssuesandt
heconsequentr
esponsi
bil
i
ties
r
elev
antt
othepr
ofessi
onal
engi
neer
ingpr
act
ice.
PO7.Env
ironmentandsust
ainabi
l
ity
:Under
standt
hei
mpactoft
hepr
ofessi
onalengi
neer
ing
sol
uti
onsi
nsoci
etalandenv
ironment
alcont
ext
s,anddemonst
rat
etheknowl
edgeof
,andneed
f
orsust
ainabl
edev
elopment
.
PO8.Et
hics:Appl
yet
hicalpr
inci
plesandcommi
ttopr
ofessi
onalet
hicsandr
esponsi
bil
i
ties
andnor
msoft
heengi
neer
ingpr
act
ice.
PO9.I
ndi
vi
dualandt
eam wor
k:Funct
ionef
fect
ivel
yasani
ndi
vi
dual
,andasamemberor
l
eaderi
ndi
ver
set
eams,
andi
nmul
ti
disci
pli
nar
yset
ti
ngs.
PO10.Communi
cat
ion:Communi
cat
eef
fect
ivel
yoncompl
exengi
neer
ingact
ivi
ti
eswi
tht
he
engi
neer
ingcommuni
tyandwi
thsoci
etyatl
arge,
suchas,
bei
ngabl
etocompr
ehendandwr
it
e
ef
fect
iver
epor
tsand desi
gn document
ati
on,makeef
fect
ivepr
esent
ati
ons,and gi
veand
r
ecei
vecl
eari
nst
ruct
ions.
PO11.Pr
ojectmanagementandf
inance:Demonst
rat
eknowl
edgeandunder
standi
ngoft
he
engi
neer
ingandmanagementpr
inci
plesandappl
ytheset
oone’
sownwor
k,asamemberand
l
eaderi
nat
eam,
tomanagepr
oject
sandi
nmul
ti
disci
pli
nar
yenv
ironment
s.
PO12.Li
fe-
longl
ear
ning:Recogni
zet
heneedf
or,andhav
ethepr
epar
ati
onandabi
l
ityt
o
engagei
nindependentandl
i
fe-
longl
ear
ningi
nthebr
oadestcont
extoft
echnol
ogi
cal
change.
CONTENTS
1.Sy
ll
abus
2.LabCy
cles
3.Do’
s&Don’
ts
4.I
nst
ruct
ionst
oSt
udent
s
5.LabCy
cleI
6.LabCy
cleI
I
7.LabCy
cleI
II
Sy
ll
abus
ANDROI
DAPPLI
CATI
ONDEVELOPMENTLAB
B.
Tech.I
VYearISem. L T PC
Cour
seCode:
IT703PC/
CS752PC 0 0 3 2
Cour
seObj
ect
ives:
Tol
ear
nhowt
odev
elopAppli
cati
onsinandroidenvi
ronment
.
Tol
ear
nhowt
odev
elopuseri
nterf
aceappli
cations.
Tol
ear
nhowt
odev
elopURLrelat
edappli
cations.
Thest
udenti
sexpect
edt
obeabl
etodot
hef
oll
owi
ngpr
obl
ems,
thoughnotl
i
mit
ed.
1.(
a)Cr
eat
eanAndroi
dappl
i
cat
iont
hatshowsHel
l
o+nameoft
heuserandr
un
i
tonanemul
ator
.
(
b)Cr
eat
eanappl
icat
iont
hattakest
henamefrom atextboxandshowshel
l
omessageal
ong
wi
tht
henameent
eredint
extbox,whent
heusercl
ickstheOKbutton.
3.Developanappl i
cationthatshowsnamesasal istandonselecti
nganamei t
shoul
dshow t hedet ai
lsoft hecandidateont henextscreenwi tha“ Back”
butt
on.Ifthescreeni srotat
edt olandscapemode( widt
hgreaterthanhei ght)
,
thenthescreenshoul dshowl istonlef
tfragmentanddet ai
lsonr i
ghtfragment
i
nsteadofsecondscr eenwithbackbut ton.UseFr agmenttransact
ionsand
Rotat
ionev entli
stener.
4.Developanapplicat
ionthatusesamenuwi th3optionsfordial
i
nganumber ,
opening a website and to send an SMS.On sel ect
ing an opt
ion,t
he
appropri
ateact
ionshouldbeinvokedusi
ngintent
s.
5.Devel
opanappl i
cat
ionthati
nsert
ssomenot if
icat
ionsi
ntoNoti
fi
cat
ionarea
andwheneveranoti
ficat
ioni
sinser
ted,i
tshoul
dshowat oastwit
hdetai
l
sof
thenot
if
icat
ion.
6.Cr eat
eanappl i
cat
iont hatusesat extfi
l
et ostor
eusernamesandpasswor ds
(tabseparatedfi
eldsandoner ecordperline)
.Whent heusersubmit
sal ogin
nameandpasswor dthroughascr een,thedetail
sshouldbeveri
fi
edwi t
hthe
textfi
ledataandift heymat ch,showadi alogsayi
ngthatlogi
nissuccessful
.
Ot her
wise,showthedi al
ogwi thLoginFail
edmessage.
R16B.
TECHCSE.
7.Cr
eat
eauserr
egi
str
ati
onappl
i
cat
iont
hatst
orest
heuserdet
ail
sinadat
abaset
abl
e.
8.Createadatabaseandausert abl
ewher ethedet
ail
soflogi
nnamesand
passwordsarestored.I
nser
tsomenamesandpasswor dsi
nit
ial
l
y.Now t
he
l
ogindetai
lsenter
edbyt heusershoul
dbev eri
fi
edwi
ththedat
abaseandan
appropr
iat
edial
ogshouldbeshownt otheuser
.
Not
e:
AndroidApplicati
onDev el
opmentwi t
hMI TAppI nventor
:Forthefi
rstoneweek,the
studentisadv i
sedtogot hroughtheAppInv ent
orfrom MITwhichgivesi
nsi
ghtinto
thevariouspropert
iesofeachcomponent .
Thest udentshouldpayat t
enti
ontothepr opert
iesofeachcomponent ,whi
char e
usedlaterinAndroidprogramming.Foll
owingareusefull
inks:
1.http://ai
2.appinv entor.mit
.edu
ht
2. t
ps:
//dr
ive.
googl
e.com/
fil
e/d/
0B8r
TtW_
91Ycl
TWF4czdBMEpZcWs/
view
ANDROI
DAPPLI
CATI
ONDEVELOPMENTLAB
Do’
s
1.Onent
eri
ngt
hel
abf
illt
hedet
ail
sinl
ogbook.
2.Shut
downt
hesyst
em pr
oper
lywhi
lel
eavi
ngt
hel
ab.
3.Keept
heComput
erl
abpr
emi
sescl
eanandt
idy.
4.Contactt
heSyst
em Admi
nist
rat
ori
fyounot
iceanyki
ndofmachi
ne
malf
unction.
Don’
ts
1.Don’
tinst
allanyappl
icat
ionsof
twar
e.
2.Don’
tdisconnectormodifyanymachi
ne,ei
therPCorperipheral
equi
pment .
3.Don’
tconnectyourpersonall
aptopmachi
neinplacesot
hert han
desi
gnated.
4.Don’
teatordrinkint
hecomput erl
ab.
5.Don’
tcar
ryyourmobi
lephones.
6.Don’
tconnectUSBst
orageDevi
cest
oPC’
s.
I
NSTRUCTI
ONSTOSTUDENTS
Af
terent
eri
ngt
hel
ab,
makeanent
ryi
nthel
ogbookpr
ovi
dingt
hespeci
fi
eddet
ail
s.
Obser
vat
ionbookandLabRecor
dshoul
dbedul
ysi
gnedbyt
heconcer
nedf
acul
tyaf
ter
t
hecompl
eti
onofeachexper
iment
,fai
l
ingwhi
chmar
kswi
l
lnotbeawar
ded.Al
l
exper
iment
smustbecompl
etedaspert
heschedul
e.
Af
tert
hecompl
eti
onofl
ab,
proper
lyshut
downt
hesy
stem.
GRADI
NG:
Theov
eral
llabev
aluat
ioni
sfor75mar
ks.I
nthat50mar
ksf
orSemest
erEnd
Exami
nat
ion and r
emai
ning 25 mar
ks wi
l
lbe awar
ded based on I
nter
nal
ev
aluat
ion.
I
nter
nal
Eval
uat
ionconsi
stsof
:
o Labi
nter
nalexami
nat
ion:Ther
ewi
l
lbet
woi
nter
nalexami
nat
ionsf
or10
mar
kseach.Thef
inalmar
ksar
eawar
dedast
heav
erageoft
woi
nter
nal
exami
nat
ionmar
ks.
o Cont
inuat
ion ev
aluat
ion i
sfor 15 mar
ks and di
str
ibut
ed f
or each
exper
imentas:
A.Exper
iment
ati
on 5mar
ks
B.Obser
vat
ion 5mar
ks
C.Recor
d 5mar
ks
1.(a)Creat
eanAndr
oidappl
icat
iont
hatshowsHel
l
o+nameoft
he
userandruni
tonanemulator
.
Cr
eat
eAndr
oidAppl
i
cat
ion:
1.
b)Cr
eat
eanappl
i
cat
iont
hatt
akest
henamef
rom at
extboxandshowshel
l
o
messageal
ongwi
tht
henameent
eredi
ntextbox,
whent
heusercl
i
ckst
heOK
but
ton.
i
mpor
tandr
oid.
app.*;
i
mpor
tandr
oid.
os.*
;
i
mpor
tandr
oid.
vi
ew.*;
i
mpor
tandr
oid.
widget.
*;
publi
cclassMainActi
vi
tyext
endsActi
vi
ty{
pri
vateButtonb;
Edi
tTextetname,
etemail
,
etpasswor
d;
TextVi
ewt v;
@Ov
err
ide
protectedv oidonCr eate(Bundlesav edInst
anceStat
e){
super.onCr eate(savedInstanceState);
setCont entView(R.layout.acti
vi
ty_main);
b=(But t
on) f
indViewBy Id(R.i
d.cl
ick)
;
tv=(TextView) f
indViewBy Id(R.i
d.di
splay);
tv.
setMov ement Met hod(newScr oll
ingMov ementMet
hod(
))
b.setOnCl i
ckListener(newVi ew.OnClickLi
stener(){
@Ov er
ri
de
publ icvoidonCl ick(Viewv ){
et name=( EditText)fi
ndViewBy I
d(R.i
d.name) ;
et email=(EditText)fi
ndViewBy I
d(R.i
d.email);
et passwor d=(EditText)fi
ndViewBy I
d(R.i
d.password);
tv.setText("YourI nput:
\n"+et name.get Text().
toStri
ng()
+"\n"+etemail.
getText
().
toSt
ri
ng(
)+"
\n"
+et
passwor
d.get
Text (
) .
toStri
ng()+"\nEnd. "
);
}
});
}
Decl
areUIEl
ement
sinXML
<?xml version="1.
0"
encoding="ut
f-
8"?>
<Linear
Lay out xmlns:
android="
htt
p:/
/schemas.
andr
oid.
com/
apk/
res/
andr
oid"
android:ori
entati
on="v
ertical
"
android:layout _width=" match_ parent"
android:layout _height="mat ch_ parent">
<TextVi ew
andr oid:i
d=" @+id/ fstTxt"
andr oid:l
ay out_widt h="wrap_ content"
andr oid:l
ay out_height ="
wr ap_ content"
andr oid:text="EnterName" />
<Edit
Text
andr oid:i
d=" @+id/ name"
andr oid:l
ay out_widt h="wrap_ content"
andr oid:l
ay out_height ="
wr ap_ content"
andr oid:ems=" 10"/ >
<Button
andr oid:i
d=" @+id/ getName"
andr oid:l
ay out_widt h="wrap_ content"
andr oid:l
ay out_height ="
wr ap_ content"
andr oid:text="GetName" />
</Li
near Lay out>
LoadXMLLay
outFi
l
efr
om anAct
ivi
ty
pr
ot ectedvoi
d onCreat
e(BundlesavedInst
anceSt
ate)
{
super .
onCreate(
savedI
nstanceState);
set Content
View(R.l
ayout.
activi
ty_
mai n)
;
}
Cr
eat
eUIEl
ementatRunt
ime
publi
ccl ass Mai nAct i
vit
y
extends AppCompat Act
ivi
ty{
@Ov err
ide
protectedv oid onCr eate(Bundlesav edI
nstanceState){
super .
onCr eate(sav edInstanceState);
Text Viewtext View1= new TextVi
ew( thi
s);
textView1.set Text (
"Name: ");
Edi t
Textedi tText1= new EditText(t
his);
editText1.setText ("
EnterName" );
But t
onbut ton1= new Button(thi
s);
but t
on1.setText ("
AddName" );
LinearLayoutli
nearLay
out= new Li
near
Lay
out
(t
his)
;
l
inearLayout.addView(
text
View1);
l
inearLayout.addView(
edit
Text1)
;
l
inearLayout.addView(
butt
on1);
setContentView(l
inear
Layout)
;
}
3.Developanappl icati
ont hatshowsnamesasal i
standonsel ect
inga
namei tshouldshow t hedet ail
soft hecandi dat
eont henextscr een
witha“ Back”button.I
ft hescreenisrotatedtolandscapemode( width
greaterthanheight),t
hent hescreenshoul dshowl i
stonl eftf
ragment
and detail
sonr ightfragmenti nstead ofsecond scr eenwi thback
button.UseFragmentt ransacti
onsandRot at
ioneventli
stener.
publ
i
ccl
assAndr
oidLi
stVi
ewAct
ivi
tyext
endsLi
stAct
ivi
ty{
@Ov
err
ide
publ
i
cvoi
donCr
eat
e(Bundl
esav
edI
nst
anceSt
ate){
super
.onCr
eat
e(sav
edI
nst
anceSt
ate)
;
/
/st
ori
ngst
ri
ngr
esour
cesi
ntoAr
ray
St
ri
ng[
]number
s={
"one"
,"
two"
,"
thr
ee"
,"
four
"}
/
/her
eyoust
oret
hear
rayofst
ri
ngy
ougotf
rom t
hedat
abase
/
/Bi
ndi
ngAr
rayt
oLi
stAdapt
er
t
his.
set
List
Adapt
er(
newAr
ray
Adapt
er<St
ri
ng>(
thi
s,R.
lay
out
.l
ist
_it
em,
R.i
d.l
abel
, number
s))
;
/
/ref
ert
heAr
ray
Adapt
erDocumenti
ndev
eloper
.andr
oid.
com
Li
stVi
ewl
v=get
List
View(
);
/
/li
steni
ngt
osi
ngl
eli
sti
tem oncl
i
ck
l
v.
set
OnI
temCl
i
ckLi
stener
(newOnI
temCl
i
ckLi
stener
(){
publ
i
cvoi
donI
temCl
i
ck(
Adapt
erVi
ew<?
>par
ent
,Vi
ewv
iew,
i
ntposi
ti
on,
longi
d){
/
/sel
ect
edi
tem
St
ri
ngnum =(
(Text
View)v
iew)
.get
Text
().
toSt
ri
ng(
);
/
/Launchi
ngnewAct
ivi
tyonsel
ect
ingsi
ngl
eLi
stI
tem
I
ntenti
=newI
ntent
(get
Appl
i
cat
ionCont
ext
(),
Singl
eLi
stI
tem.
class)
;
/
/sendi
ngdat
atonewact
ivi
ty
i
.put
Ext
ra(
"number
",num)
;
st
art
Act
ivi
ty(
i)
;
}
}
);
ThesecondAct
ivi
tyt
odi
spl
ayt
hePar
ti
cul
ari
tem y
ouhav
ecl
i
ckedshoul
dbe
publ
i
ccl
assSi
ngl
eLi
stI
tem ext
endsAct
ivi
ty{
@Ov
err
ide
publ
i
cvoi
donCr
eat
e(Bundl
esav
edI
nst
anceSt
ate){
super
.onCr
eat
e(sav
edI
nst
anceSt
ate)
;
t
his.
set
Cont
ent
View(
R.l
ayout
.si
ngl
e_l
i
st_
item_
view)
;
Text
Viewt
xtPr
oduct=(
Text
View)f
indVi
ewBy
Id(
R.i
d.pr
oduct
_label
);
I
ntenti
=get
Int
ent
();
/
/get
ti
ngat
tachedi
ntentdat
a
St
ri
ngpr
oduct=i
.get
Str
ingExt
ra(
"number
");
/
/di
spl
ayi
ngsel
ect
edpr
oductname
t
xtPr
oduct
.set
Text
(pr
oduct
);
4.Devel
opanappl i
cati
onthatusesamenuwi th3opti
onsf ordi
ali
nga
number,openi
ngawebsiteandtosendanSMS.Onselect
inganopti
on,
theappr
opriat
eacti
onshouldbei
nvokedusi
ngint
ent
s.
x
<?ml
ver
sion="
1.0"encodi
ng="
utf
-8"
?>
<menuxml ns:androi
d="
ht t
p://schemas.andr
oid.
com/
apk/
res/
andr
oid"
>
<i
tem android:
id="
@+id/ new_game"
andr
oid:i
con="@drawabl e/i
c_new_game"
andr
oid:ti
tl
e="@st
ring/new_ game"
andr
oid:showAsAction="if
Room" /
>
<i
tem android:
id="
@+id/ hel
p"
andr
oid:i
con="@drawabl e/i
c_hel
p"
andr
oid:ti
tl
e="@st
ring/help"/>
</
menu>
<?xml ver
sion=" 1.0"encodi ng="utf-8"?
>
<menuxml ns:andr oid="http:
//schemas. andr
oid.
com/
apk/
res/
andr
oid"
>
<i
tem andr oid:id="@+i d/fi
l
e"
android:t
itle="@st ri
ng/fil
e">
<!-
-"fi
l
e"submenu- ->
<menu>
<it
em andr oid:i
d=" @+id/create_new"
andr oid:ti
tl
e="@st ri
ng/cr eate_
new"/>
<it
em andr oid:i
d=" @+id/open"
andr oid:ti
tl
e="@st ri
ng/open"/ >
</menu>
</i
tem>
</menu>
@Ov err
ide
publ
icbooleanonCr eateOpti
onsMenu(Menumenu){
MenuInflat
erinfl
ater=getMenuInf
lat
er(
);
i
nflat
er.
infl
ate(R.
menu. game_menu,menu);
r
eturntr
ue;
}
@Ov erri
de
publi
cbooleanonOpt i
onsIt
emSel
ect
ed(
MenuI
tem i
tem){
//Handleitem select
ion
switch(i
tem. get
It
emI d(
)){
caseR.id.new_game:
newGame( )
;
ret
urntr
ue;
caseR.i
d.hel
p:
showHelp(
);
ret
urntr
ue;
defaul
t:
ret
urnsuper.
onOpt
ionsI
temSel
ect
ed(
it
em)
;
}
}
5.Dev el
opanappl
i
cat i
onthatinser
tssomenotif
icat
ionsint
oNoti
fi
cati
on
areaandwheneveranot i
fi
cati
onisi
nser
ted,
itshouldshowatoastwit
h
detail
soft
henoti
ficat
ion.
Act
ivi
ty_
mai
n.xml
<?
xml
ver
sion="
1.0"encodi
ng="
utf
-8"
?>
<Rel
ati
veLay
out
xml
ns:
andr
oid="
htt
p:/
/schemas.
andr
oid.
com/
apk/
res/
andr
oid"
xml
ns:
tool
s="
htt
p:/
/schemas.
andr
oid.
com/
tool
s"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="mat
ch_
par
ent
"
andr
oid:
paddi
ngBot
tom="
@di
men/
act
ivi
ty_
ver
ti
cal
_mar
gin"
andr
oid:
paddi
ngLef
t="
@di
men/
act
ivi
ty_
hor
izont
al_
mar
gin"
andr
oid:
paddi
ngRi
ght
="@di
men/
act
ivi
ty_
hor
izont
al_
mar
gin"
andr
oid:
paddi
ngTop="
@di
men/
act
ivi
ty_
ver
ti
cal
_mar
gin"
t
ool
s:cont
ext
="com.
jour
nal
dev
.not
if
icat
ions.
Mai
nAct
ivi
ty"
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
wrap_
cont
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="CREATENOTI
FICATI
ON"
andr
oid:
i
d="
@+i
d/but
ton"
andr
oid:
l
ayout
_al
i
gnPar
ent
Top="
tr
ue"
andr
oid:
l
ayout
_al
i
gnPar
ent
Right
="t
rue"
andr
oid:
l
ayout
_al
i
gnPar
ent
End="
tr
ue"
andr
oid:
l
ayout
_al
i
gnPar
ent
Lef
t="
tr
ue"
andr
oid:
l
ayout
_al
i
gnPar
ent
Star
t="
tr
ue"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
wrap_
cont
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="CANCELNOTI
FICATI
ON"
andr
oid:
i
d="
@+i
d/but
ton2"
andr
oid:
l
ayout
_bel
ow="
@+i
d/but
ton"
andr
oid:
l
ayout
_al
i
gnRi
ght
="@+i
d/but
ton"
andr
oid:
l
ayout
_al
i
gnEnd="
@+i
d/but
ton"
andr
oid:
l
ayout
_al
i
gnPar
ent
Lef
t="
tr
ue"
andr
oid:
l
ayout
_al
i
gnPar
ent
Star
t="
tr
ue"/
>
</
Rel
ati
veLay
out
>
Mai
nAci
vi
ty.
Jav
a
packagecom.
jour
nal
dev
.not
if
icat
ions;
i
mpor
tandr
oid.
app.
Not
if
icat
ionManager
;
i
mpor
tandr
oid.
app.
Pendi
ngI
ntent
;
i
mpor
tandr
oid.
cont
ent
.Cont
ext
;
i
mpor
tandr
oid.
cont
ent
.I
ntent
;
i
mpor
tandr
oid.
graphi
cs.
Bit
mapFact
ory
;
i
mpor
tandr
oid.
net
.Ur
i;
i
mpor
tandr
oid.
suppor
t.
v7.
app.
AppCompat
Act
ivi
ty;
i
mpor
tandr
oid.
os.
Bundl
e;
i
mpor
tandr
oid.
suppor
t.
v7.
app.
Not
if
icat
ionCompat
;
i
mpor
tandr
oid.
widget
.Toast
;
i
mpor
tbut
ter
kni
fe.
But
ter
Kni
fe;
i
mpor
tbut
ter
kni
fe.
OnCl
i
ck;
publ
i
ccl
assMai
nAct
ivi
tyext
endsAppCompat
Act
ivi
ty{
@Ov
err
ide
pr
otect
edv
oidonCr
eat
e(Bundl
esav
edI
nst
anceSt
ate){
super
.onCr
eat
e(sav
edI
nst
anceSt
ate)
;
set
Cont
ent
View(
R.l
ayout
.act
ivi
ty_
mai
n);
But
ter
Kni
fe.
inj
ect
(t
his)
;
@OnCl
i
ck(
R.i
d.but
ton)
publ
i
cvoi
dsendNot
if
icat
ion(
){
Not
if
icat
ionCompat
.Bui
l
der bui
l
der = new
Not
if
icat
ionCompat
.Bui
l
der
(thi
s);
bui
l
der
.set
Smal
l
Icon(
andr
oid.
R.dr
awabl
e.i
c_di
alog_
aler
t);
I
ntent i
ntent = new I
ntent
(I
ntent
.ACTI
ON_
VIEW,
Ur
i.
par
se(
"ht
tps:
//www.
jour
nal
dev
.com/
"))
;
Pendi
ngI
ntentpendi
ngI
ntent=Pendi
ngI
ntent
.get
Act
ivi
ty(
thi
s,0,
int
ent
,0)
;
bui
l
der
.set
Cont
ent
Int
ent
(pendi
ngI
ntent
);
bui
l
der
.set
Lar
geI
con(
Bit
mapFact
ory
.decodeResour
ce(
get
Resour
ces(
),
R.
mipmap.
ic_
launcher
));
bui
l
der
.set
Cont
ent
Tit
le(
"Not
if
icat
ionsTi
tl
e")
;
bui
l
der
.set
Cont
ent
Text
("
Yournot
if
icat
ioncont
enther
e."
);
bui
l
der
.set
SubText
("
Tapt
ovi
ewt
hewebsi
te.
")
;
Not
if
icat
ionManager not
if
icat
ionManager =
(
Not
if
icat
ionManager
)get
Syst
emSer
vice(
NOTI
FICATI
ON_
SERVI
CE)
;
/
/Wi
l
ldi
spl
ayt
henot
if
icat
ioni
nthenot
if
icat
ionbar
not
if
icat
ionManager
.not
if
y(1,
bui
l
der
.bui
l
d()
);
@OnCl
i
ck(
R.i
d.but
ton2)
publ
i
cvoi
dcancel
Not
if
icat
ion(
){
St
ri
ngns=Cont
ext
.NOTI
FICATI
ON_
SERVI
CE;
Not
if
icat
ionManager nMgr = (
Not
if
icat
ionManager
)
get
Appl
i
cat
ionCont
ext
().
get
Syst
emSer
vice(
ns)
;
nMgr
.cancel
(1)
;
6.
Creat
eanappl
i
cat
iont
hatusesat
extf
il
etost
oreusernamesandpasswor
ds(
tab
separ
atedf
iel
dsandoner
ecor
dperl
i
ne)
i
mpor
tjav
a.i
o.Fi
l
e;
i
mpor
tjav
a.i
o.Fi
l
eOut
put
Str
eam;
i
mpor
tjav
a.i
o.Fi
l
eReader
;
i
mpor
tjav
a.i
o.Fi
l
eWr
it
er;
publ
i
ccl
assMai
nAct
ivi
tyext
endsAppCompat
Act
ivi
ty{
Edi
tTex
tCodNum;
Edi
tTex
tPl
tNum;
Radi
oBut
tonr
adBut
A;
Radi
oBut
tonr
adBut
D;
Radi
oBut
tonr
adBut
S;
Radi
oBut
tonr
adBut
R;
Radi
oBut
tonr
adBut
O;
Radi
oBut
tonr
adBut
I;
@Ov
err
ide
pr
otect
edv
oidonCr
eat
e(Bundl
esav
edI
nst
anceSt
ate){
super
.onCr
eat
e(sav
edI
nst
anceSt
ate)
;
set
Cont
ent
View(
R.l
ayout
.act
ivi
ty_
mai
n);
Tool
bart
ool
bar=(
Tool
bar
)fi
ndVi
ewBy
Id(
R.i
d.t
ool
bar
);
set
Suppor
tAct
ionBar
(tool
bar
);
CodNum =(
Edi
tText
)fi
ndVi
ewBy
Id(
R.i
d.CodNum)
;
Pl
tNum =(
Edi
tText
)fi
ndVi
ewBy
Id(
R.i
d.Pl
tNum)
;
r
adBut
A=(
Radi
oBut
ton)f
indVi
ewBy
Id(
R.i
d.r
adBut
A);
r
adBut
D=(
Radi
oBut
ton)f
indVi
ewBy
Id(
R.i
d.r
adBut
D);
r
adBut
S=(
Radi
oBut
ton)f
indVi
ewBy
Id(
R.i
d.r
adBut
S);
r
adBut
R=(
Radi
oBut
ton)f
indVi
ewBy
Id(
R.i
d.r
adBut
R);
r
adBut
O=(
Radi
oBut
ton)f
indVi
ewBy
Id(
R.i
d.r
adBut
O);
r
adBut
I=(
Radi
oBut
ton)f
indVi
ewBy
Id(
R.i
d.r
adBut
I)
;
checkBoxMw=(
CheckBox
)fi
ndVi
ewBy
Id(
R.i
d.checkBoxMw)
;
checkBoxG7=(
CheckBox)f
indVi
ewBy
Id(
R.i
d.checkBoxG7)
;
checkBoxGw=(
CheckBox)f
indVi
ewBy
Id(
R.i
d.checkBoxGw)
;
checkBoxF=(
CheckBox)f
indVi
ewBy
Id(
R.i
d.checkBoxF)
;
f
inal
Fil
eOut
put
Str
eam out
put
Str
eam;
St
ri
ngf
il
eName="
feeder
Txt
Fil
e";
But
tonbut
tonS=(
But
ton)f
indVi
ewBy
Id(
R.i
d.but
tonS)
;
but
tonS.
set
OnCl
i
ckLi
stener
(newVi
ew.
OnCl
i
ckLi
stener
(){
@Ov
err
ide
publ
i
cvoi
donCl
i
ck(
Viewv
){
t
ry{
out
put
Str
eam =openFi
l
eOut
put
(fi
l
eName,
CONTEXT.
MOOD_
PRI
VATE)
;
out
put
Str
eam.
wri
te(
Str
ing.
get
Byt
es(
));
out
put
Str
eam.
close(
);
}
cat
ch(
Except
ione)
{
e.
pri
ntSt
ackTr
ace(
);
}
);
But
tonbut
tonE=(
But
ton)f
indVi
ewBy
Id(
R.i
d.but
tonE)
;
but
tonE.
set
OnCl
i
ckLi
stener
(newVi
ew.
OnCl
i
ckLi
stener
(){
@Ov
err
ide
publ
i
cvoi
donCl
i
ck(
Viewv
){
/
/Edi
ti
ngt
otextf
il
e.
}
);
7.
Creat
eauserr
egi
str
ati
onappl
i
cat
iont
hatst
orest
heuserdet
ail
sinadat
abase
tabl
e.
act
ivi
ty_
logi
n.xml
.
<?
xml
ver
sion="
1.0"encodi
ng="
utf
-8"
?>
<andr
oid.
suppor
t.
v4.
widget
.Nest
edScr
oll
View
xml
ns:
andr
oid="
htt
p:/
/schemas.
andr
oid.
com/
apk/
res/
andr
oid"
xml
ns:
tool
s="
htt
p:/
/schemas.
andr
oid.
com/
tool
s"
andr
oid:
i
d="
@+i
d/nest
edScr
oll
View"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="mat
ch_
par
ent
"
andr
oid:
backgr
ound="
@col
or/
col
orBackgr
ound"
andr
oid:
paddi
ngBot
tom="
20dp"
andr
oid:
paddi
ngLef
t="
20dp"
andr
oid:
paddi
ngRi
ght
="20dp"
andr
oid:
paddi
ngTop="
20dp"
t
ool
s:cont
ext
=".
act
ivi
ti
es.
Logi
nAct
ivi
ty"
>
<andr
oid.
suppor
t.
v7.
widget
.Li
near
Lay
out
Compat
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="mat
ch_
par
ent
"
andr
oid:
ori
ent
ati
on="
ver
ti
cal
">
<andr
oid.
suppor
t.
v7.
widget
.AppCompat
ImageVi
ew
andr
oid:
l
ayout
_wi
dth="
wrap_
cont
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
l
ayout
_gr
avi
ty="
cent
er_
hor
izont
al"
andr
oid:
l
ayout
_mar
ginTop="
40dp"
andr
oid:
src="
@dr
awabl
e/l
ogo"/
>
<andr
oid.
suppor
t.
desi
gn.
widget
.Text
Input
Lay
out
andr
oid:
i
d="
@+i
d/t
ext
Input
Lay
out
Emai
l
"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
l
ayout
_mar
ginTop="
40dp"
>
<andr
oid.
suppor
t.
desi
gn.
widget
.Text
Input
Edi
tText
andr
oid:
i
d="
@+i
d/t
ext
Input
Edi
tText
Emai
l
"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
hint
="@st
ri
ng/
hint
_emai
l
"
andr
oid:
i
nput
Type="
text
"
andr
oid:
maxLi
nes="
1"
andr
oid:
text
Col
or="
@andr
oid:
col
or/
whi
te"/
>
</
andr
oid.
suppor
t.
desi
gn.
widget
.Text
Input
Lay
out
>
<andr
oid.
suppor
t.
desi
gn.
widget
.Text
Input
Lay
out
andr
oid:
i
d="
@+i
d/t
ext
Input
Lay
out
Passwor
d"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
l
ayout
_mar
ginTop="
20dp"
>
<andr
oid.
suppor
t.
desi
gn.
widget
.Text
Input
Edi
tText
andr
oid:
i
d="
@+i
d/t
ext
Input
Edi
tText
Passwor
d"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
hint
="@st
ri
ng/
hint
_passwor
d"
andr
oid:
i
nput
Type="
text
Passwor
d"
andr
oid:
maxLi
nes="
1"
andr
oid:
text
Col
or="
@andr
oid:
col
or/
whi
te"/
>
</
andr
oid.
suppor
t.
desi
gn.
widget
.Text
Input
Lay
out
>
<andr
oid.
suppor
t.
v7.
widget
.AppCompat
But
ton
andr
oid:
i
d="
@+i
d/appCompat
But
tonLogi
n"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
l
ayout
_mar
ginTop="
40dp"
andr
oid:
backgr
ound="
@col
or/
col
orText
Hint
"
andr
oid:
text
="@st
ri
ng/
text
_logi
n"/
>
<andr
oid.
suppor
t.
v7.
widget
.AppCompat
Text
View
andr
oid:
i
d="
@+i
d/t
ext
ViewLi
nkRegi
ster
"
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
l
ayout
_mar
ginTop="
30dp"
andr
oid:
grav
ity
="cent
er"
andr
oid:
text
="@st
ri
ng/
text
_not
_member
"
andr
oid:
text
Size="
16dp"/
>
</
andr
oid.
suppor
t.
v7.
widget
.Li
near
Lay
out
Compat
>
</
andr
oid.
suppor
t.
v4.
widget
.Nest
edScr
oll
View>
8.Createadatabaseandausert ablewher
ethedetai
l
sofl ogi
nnames
andpasswor dsarestored.I
nser
tsomenamesandpasswor dsini
ti
all
y.
Now t hel
ogindetail
sent er
edbyt heusershoul
dbev eri
fi
edwi t
hthe
databaseandanappr opri
atedi
alogshoul
dbeshowntot heuser
.
packagecom.
exampl
e.sai
ramkr
ishna.
myappl
i
cat
ion;
i
mpor
tandr
oid.
cont
ent
.Cont
ext
;
i
mpor
tandr
oid.
cont
ent
.I
ntent
;
i
mpor
tandr
oid.
suppor
t.
v7.
app.
Act
ionBar
Act
ivi
ty;
i
mpor
tandr
oid.
os.
Bundl
e;
i
mpor
tandr
oid.
vi
ew.
Key
Event
;
i
mpor
tandr
oid.
vi
ew.
Menu;
i
mpor
tandr
oid.
vi
ew.
MenuI
tem;
i
mpor
tandr
oid.
vi
ew.
View;
i
mpor
tandr
oid.
widget
.Adapt
erVi
ew;
i
mpor
tandr
oid.
widget
.Ar
ray
Adapt
er;
i
mpor
tandr
oid.
widget
.Adapt
erVi
ew.
OnI
temCl
i
ckLi
stener
;
i
mpor
tandr
oid.
widget
.Li
stVi
ew;
i
mpor
tjav
a.ut
il
.Ar
ray
List
;
i
mpor
tjav
a.ut
il
.Li
st;
publ
i
ccl
assMai
nAct
ivi
tyext
endsAct
ionBar
Act
ivi
ty{
publ
i
cfi
nal
stat
icSt
ri
ngEXTRA_
MESSAGE="
MESSAGE"
;
pr
ivat
eLi
stVi
ewobj
;
DBHel
permy
db;
@Ov
err
ide
pr
otect
edv
oidonCr
eat
e(Bundl
esav
edI
nst
anceSt
ate){
super
.onCr
eat
e(sav
edI
nst
anceSt
ate)
;
set
Cont
ent
View(
R.l
ayout
.act
ivi
ty_
mai
n);
my
db=newDBHel
per
(thi
s);
Ar
ray
Listar
ray
_li
st=my
db.
get
All
Cot
act
s()
;
Ar
rayAdapt
erar
ray
Adapt
er=newAr
ray
Adapt
er(
thi
s,
andr
oid.
R.l
ayout
.si
mpl
e_l
i
st_
item_
1,
ar
ray_l
ist
);
obj
=(Li
stVi
ew)
fi
ndVi
ewBy
Id(
R.i
d.l
i
stVi
ew1)
;
obj
.set
Adapt
er(
arr
ayAdapt
er)
;
obj
.set
OnI
temCl
i
ckLi
stener
(newOnI
temCl
i
ckLi
stener
(){
@Ov
err
ide
publ
i
cvoi
donI
temCl
i
ck(
Adapt
erVi
ew<?
>ar
g0,
Viewar
g1,
intar
g2,
l
ongar
g3){
/
/TODOAut
o-gener
atedmet
hodst
ub
i
nti
d_To_
Sear
ch=ar
g2+1;
Bundl
edat
aBundl
e=newBundl
e()
;
dat
aBundl
e.put
Int
("
id"
,id_
To_
Sear
ch)
;
I
ntenti
ntent=newI
ntent
(get
Appl
i
cat
ionCont
ext
(),
Displ
ayCont
act
.cl
ass)
;
i
ntent
.put
Ext
ras(
dat
aBundl
e);
st
art
Act
ivi
ty(
int
ent
);
}
);
}
@Ov
err
ide
publ
i
cbool
eanonCr
eat
eOpt
ionsMenu(
Menumenu){
/
/Inf
lat
ethemenu;
thi
saddsi
temst
otheact
ionbari
fiti
spr
esent
.
get
MenuI
nfl
ater
().
inf
lat
e(R.
menu.
menu_
mai
n,menu)
;
r
etur
ntr
ue;
@Ov
err
ide
publ
i
cbool
eanonOpt
ionsI
temSel
ect
ed(
MenuI
tem i
tem)
{
super
.onOpt
ionsI
temSel
ect
ed(
it
em)
;
swi
tch(
it
em.
get
It
emI
d()
){
caseR.
id.
it
em1:
Bundl
edat
aBundl
e=newBundl
e()
;
dat
aBundl
e.put
Int
("
id"
,0)
;
I
ntenti
ntent=newI
ntent
(get
Appl
i
cat
ionCont
ext
(),
Displ
ayCont
act
.cl
ass)
;
i
ntent
.put
Ext
ras(
dat
aBundl
e);
st
art
Act
ivi
ty(
int
ent
);
r
etur
ntr
ue;
def
aul
t:
r
etur
nsuper
.onOpt
ionsI
temSel
ect
ed(
it
em)
;
}
publ
i
cbool
eanonKey
Down(
intkey
code,
Key
Eventev
ent
){
i
f(key
code==Key
Event
.KEYCODE_
BACK){
mov
eTaskToBack(
true)
;
r
etur
nsuper
.onKey
Down(
key
code,
event
);