You are on page 1of 34

Android Development Tutorial

Nikhil Yadav
CSE40816/60816 - erva!ive "ealth
#all $011

%utline

Settin& up the Android Development


Environment '(indo)!*

Starter! Android +"ello (orld, empt- pro.e/t

Android pro.e/t /omponent!

E0ample1 Ta22ed appli/ation pro.e/t

A//e!!in& Sen!or! on an Android Devi/e1


3S4 a//elerometer! and the 3oo&le A5

Data2a!e /onne/tion! 6 7o/al S87ite and


remote a//e!!

Android Development Environment

Do)nload the late!t 9D: '9ava di!tri2ution*

Do)nload the E/lip!e 5DE 'e;&; 3alileo* <rom1


)));e/lip!e;or&/do)nload!/

5n!tall the Android SD: !tarter pa/ka&e <rom1


http1//developer;android;/om/!dk/inde0;html

5n E/lip!e4 in!tall the ADT 'Android Developer


Tool!* plu&in1
http1//developer;android;/om/!dk/e/lip!e-adt;html

5n!tru/tion! on !ettin& up the SD: and


development Environment /an 2e <ound on1
http1//developer;android;/om/!dk/in!tallin&;html

The Android SD: !tarter pa/ka&e

Not the <ull development environment4 in/lude!


the /ore SD: tool!

:eep tra/k o< )here -ou have do)nloaded thi!


it i! re=uired <or the ADT plu&in !etup4 e;&;
C1>ro&ram #ile!>android-!dk-)indo)!>plat<orm-
tool!?

@!e<ul <or +ad2, /ommand!



The ADT plu&in

3ive! a//e!! to Android development tool!


<rom )ithin the E/lip!e 5DE

Automate! the pro/e!! o< 2uildin& a ne)


Android pro.e/t 2- !ettin& up all the 2a!i/ <ile!
needed <or development

Allo)! /ode !i&nin& o< -our app !o it /an 2e


di!tri2uted

5n!tallin& the ADT plu&in
'7ink1 http1//developer;android;/om/!dk/e/lip!e-adt;htmlAin!tallin&*
To simplify ADT setup, it is recommend installing the Android SDK prior to installing ADT
.Eclipse 3.5 (Galileo) and 3.6 (Helios)
1.Start Eclipse, then select Help>Install New Software....
.!lic" #dd, in the top$ri%ht corner.
3.In the Add Repository dialo% that appears, enter &#'( )l*%in& for the Name and
the followin% +,- for the Location.
https.//dl$ssl.%oo%le.co0/android/eclipse/
Note. If 1o* ha2e tro*3les tr1 *sin% &http& instead of &https4!lic" 56.
7.In the Available Software dialo%, select the chec"3o8 ne8t to Developer Tools
and clic" Ne8t.
5.In the ne8t window, 1o*9ll see a list of the tools to 3e downloaded. !lic" Ne8t.
6.,ead and accept the license a%ree0ents, then clic" :inish.
;.<hen the installation co0pletes, restart Eclipse.

Con<i&urin& the ADT plu&in
1;Sele/t <indow?)references...to open the re<eren/e! panel 'Ba/ %S
C1Eclipse?)references*;
$;Sele/t #ndroid <rom the le<t panel;
D;#or the SDK Location in the main panel4 /li/k =rowse...and lo/ate -our
do)nloaded SD: dire/tor- 'e;&; C1>ro&ram #ile!>android-!dk-)indo)!>*
4;Cli/k #ppl14 then 56

Android SD: and AED mana&er

Add -our virtual development devi/e! u!in& thi!

AED i! a tar&et devi/e !imulator1 no !en!or!




Android SD: and AED Bana&er

@!ed <or updatin& Android SD: tool! et/;



ointer!
@pdate the !-!temF! AT" varia2le to re/o&niGe t)o <older! in!ide -our
android$sd"$winwows; The <ir!t i!1 tools and the !e/ond i! platfor0$
tools;
1;(indo)! ? Start ? Control anel ? S-!tem ? Advan/ed ? Environment
Earia2le! ? S-!tem Earia2le! ? AT" ? Edit
$;Add re<eren/e! to the !u2-<older! mentioned a2ove; 5n thi! e0ample1
/1>android-!dk-)indo)!>tool!HC1>android-!dk-)indo)!>plat<orm-tool!H
D;%:
Bake !ure 9ava and E/lip!e Environment! and path varia2le! are !etup
/orre/tl-1
So0e interestin% t*torials on #ndroid pro>ects can 3e fo*nd on.
http1//)));hometutorial!;/om/&oo&le-android;html

Starter!1 +"ello (orld,



%n/e -ou /omplete the Ne) ro.e/t (iGard4 ADT /reate! the <ollo)in&
<older! and <ile! in -our ne) pro.e/t1
Isrc/ 5n/lude! -our !tu2 A/tivit- 9ava <ile; All other 9ava <ile! <or -our
appli/ation &o here;

I<Android Version>/ 'e;&;4 Android 1;J/* 5n/lude! the android;.ar <ile
that -our appli/ation )ill 2uild a&ain!t;
I%en/ Thi! /ontain! the 9ava <ile! &enerated 2- ADT4 !u/h a! -our
K;.ava <ile and inter<a/e! /reated <rom A5D7 <ile!;
Iassets/Thi! i! empt-; You /an u!e it to !tore ra) a!!et <ile!;

Ires/A <older <or -our appli/ation re!our/e!4 !u/h a! drawable <ile!4
layout <ile!4 string value!4 et/;
I#ndroid?anifest.80l The Android Bani<e!t <or -our pro.e/t;
Idefa*lt.propertiesThi! <ile /ontain! pro.e/t !ettin&!4 !u/h a! the 2uild
tar&et;
Android ro.e/t Component!








A Ta22ed appli/ation


mainmenu;.ava

main;0ml

Android Bani<e!t;0ml

ta2!;.ava

A//e!!in& Sen!or!
There are variou! !en!or! on the Android
phone!4 e;&; 3S4 /amera4 a//elerometer
Cannot 2e te!ted on Simulator
Tutorial and !ample !our/e /ode to u!e 3S
and a//elerometer !en!or! availa2le !oon
@!in& the (i-#i and Lluetooth 5nter<a/e!
in!tru/tion! on1
http1//)));tutorial<orandroid;/om/$00M/10/turn-o<<-turn-on-)i<i-in-android-u!in&;html
http1//developer;android;/om/&uide/topi/!/)irele!!/2luetooth;html

3S Sen!or A//e!!

To u!e 3S <un/tionalit- in -our Android appli/ation4 -ouNll


need to add the ACCESSO#5NEO7%CAT5%N permi!!ion to
the AndroidBani<e!t;0ml <ile;
<uses-permission
android:name="android.permission.ACCSS!"#$!L%CAT#%$" />

5n Android4 lo/ation-2a!ed !ervi/e! are provided 2- the


7o/ationBana&er /la!! lo/ated in the android;lo/ation
pa/ka&e;

@!in& the 7o/ationBana&er /la!!4 -our appli/ation /an


o2tain periodi/ update! o< the devi/eN! &eo&raphi/al lo/ation!
a! )ell a! <ire an intent )hen it enter! the pro0imit- o< a
/ertain lo/ation;

A//elerometer and A//e!! to other
Sen!or!

An in!tan/e o< the Sen!orBana&er i! re=uired in order to


retrieve in<ormation! a2out the !upported !en!or!;

No permi!!ion i! re=uired to a//e!! the !en!or !ervi/e; 5t i!


then po!!i2le to retrieve the li!t o< availa2le !en!or! o< a
/ertain t-pe;

#or an a//elerometer !en!or4 the t-pe to u!e i! &iven 2- the


Sen!or;TYEOACCE7EK%BETEK /on!tant;

5< at lea!t one Sen!or e0i!t!4 it i! po!!i2le to re&i!ter a


Sen!orEvent7i!tener <or a Sen!or o< the li!t;

5t i! po!!i2le to !pe/i<- the deliverin& rate <or !en!or


event!; Spe/i<ied rate mu!t 2e one o< 1

Sen!orBana&er;SENS%KODE7AYO#ASTEST 1 a! <a!t a!
po!!i2le
Sen!orBana&er;SENS%KODE7AYO3ABE 1 rate !uita2le <or
&ame
Sen!orBana&er;SENS%KODE7AYON%KBA7 1 normal rate
Sen!orBana&er;SENS%KODE7AYO@5 1 rate !uita2le <or @5
Thread

Android and Data2a!e!

A//e!! to remote data2a!e e;&; B-S87 /an


o//ur u!in& a " !/ript ho!ted on the !erver
per<ormin& the =uer- and 9S%N <ormattin& <or
data e0/han&e <or re<eren/e /he/k out the
e0ample at1
http1//)));helloandroid;/om/tutorial!//onne/tin&-
m-!=l-data2a!e

7o/al li&ht )ei&ht data2a!e !-!tem;


http1//developer;android;/om/re<eren/e/android/d
ata2a!e/!=lite/S87iteData2a!e;html

8ue!tion!P
http1//developer;android;/om/inde0;html

You might also like