Professional Documents
Culture Documents
Android Development Tutorial: Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011
Android Development Tutorial: Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011
%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
5n!tru/tion! on !ettin& up the SD: and development Environment /an 2e <ound on1 http1//developer;android;/om/!dk/in!tallin&;html
: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<ormtool!?
Automate! the pro/e!! o< 2uildin& a ne) Android pro.e/t 2- !ettin& up all the 2a!i/ <ile! needed <or development
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.
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
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
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;&; 3 S4 /amera4 a//elerometer
Tutorial and !ample !our/e /ode to u!e 3 S and a//elerometer !en!or! availa2le !oon
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
3 S Sen!or A//e!!
To u!e 3 S <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;
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;
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;TY EOACCE7EK%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
http1//)));helloandroid;/om/tutorial!//onne/tin&m-!=l-data2a!e
http1//developer;android;/om/re<eren/e/android/d ata2a!e/!=lite/S87iteData2a!e;html
8ue!tion!P
http1//developer;android;/om/inde0;html