Android Development Tutorial: Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011
This document provides an outline for an Android development tutorial. It discusses setting up the Android development environment, creating a starter "Hello World" project, Android project components, accessing sensors on an Android device like the accelerometer, and database connections using SQLite and remote access. Specific topics covered include downloading required software, configuring the ADT plugin for Eclipse, the components of an Android project, adding permissions for sensors, and accessing the accelerometer and other sensors programmatically.
Android Development Tutorial: Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011
This document provides an outline for an Android development tutorial. It discusses setting up the Android development environment, creating a starter "Hello World" project, Android project components, accessing sensors on an Android device like the accelerometer, and database connections using SQLite and remote access. Specific topics covered include downloading required software, configuring the ADT plugin for Eclipse, the components of an Android project, adding permissions for sensors, and accessing the accelerometer and other sensors programmatically.
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!;
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
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