570 likes | 594 Views
Learn about Android software development tools, key concepts, creating apps, market statistics, device variety, and user interaction. Understand the design step, feature prioritization, user interface design, and incremental development approach.
E N D
Introduction toAndroid Software Development • T-110.5130 Mobile Systems programming • Juha-Matti Liukkonen • juha-matti.liukkonen@reaktor.com
Introduction toAndroid Software Development • Introduction to Android • Development Tools • Interlude: The Design Step • Key AndroidConcepts • PuttingYourAppTogether • Where to gonext
Introduction to Android • World’smostpopular mobile operating system
Android = Linux • Linux kernel • MostAndroidspecificmechanismsnowincluded in mainstream Linux kernel – wakelocks, binder, etc • Customstartupscriptmechanism • A simple, classicinit.rcscriptsolution • (Generic) applicationswritten in Java • Applications donotneed to careaboutunderlyingprocessorcapabilities • Custom Java runtime (actually 2: Dalvik, AndroidRunTime) • Optimized for lowfootprint = suitable for mobile devices
1.400.000.000 users • In 2015, 82% of new smartphonesranAndroid • 1.4 billionusers, 1.5 million new devicesactivatedeveryday • 54% totalmarketshare (and obviouslyrising) • 78% of Chinesemarket • 70% of tabletmarket • 4000+ differentdevicemodels • 400+ devicemanufacturers • Alsoused in wearables, TVs and cars • Small segmentssofar
Mostdevicesareneverupdated Main versions: 6.0 2015 4.4W (watch) 2015 5.x 2014 4.4 2014 4.x 2012-2013 4.0 2011-2012 3.0 2011 2.x 2010
Manyscreensizes, formfactors Also – differentinteractionmodels!
Varietypros & cons • Con: your software willnotworkproperly on mostAndroiddevices • Chooseyourtargetdeviceswisely to reachyourtargetedusers! • Customizedlayouts, graphics, interactionmodelsneeded to supportdifferentdevicetypes • Somehandled via Play Storedevicefilters, somebyappmanifesttags, somebyresources, someyouneed to handle in yourcode • Pro: the sameprogrammingmodelworks on allAndroiddevices • Ifyouknowhow to create software for an Androidphone, youalsoknowhow to doit for tablets, smartwatches, cars and TVs
Takeaway • Android is basically Java on Linux • It’seasy to reachgazillions of users with Androidapps • Varietymakesithard to writegoodAndroidapps
Development Tools • Whatyouneed to getyourappdone
The good and the bad news • Android Studio containseverythingyouneed (yay 2016!) • …just that it usually doesn’t contain it by default • For very simple apps, only for latest devices, defaults are OK • So, after Android Studio installation, remember to: • Configure -> SDK Manager • Install the Android versions you want to build software for • Also advisable to install the most common support libraries
Gettingready to do software • Press ”OK” – nowyourenvironment is set up • Android Studio willgenerateapplicationskeletons for common applicationtypes for you • Allyouneed to do is …”fill in the details”
Nowthingsgetinteresting • What to choose as Activity? • Whatdoesyour software actuallyneed to do? • This is the stagewhenweusuallydo…
Interlude:The Design Step • The criticalstepbeforeactuallywritingany software(nothing to do with Android as such)
Understandyouruse case • Whatproblemdoesyourappsolve? • For whom? (Concreteexample, no abstractpersons!) • In whichsituationdoes the problemoccur? • How does the userlaunchyourapp in thatsituation? • How doesyourappfulfill the user’sneed?
Example: AdhocIdeas • Problem: helpingad-hocideasbestored (eg. appideas!) • User: my colleague Antti (willusehim for testing) • Where: in public transport, duringworkcommutes (noisyenvironmentsoaudiorecordingisn’tpolite & doesn’twork) • Launch: shortcuticon on home screen • Fulfillment: it’seasy to writefree-formtextimmediately
Identify & prioritizefeatures This is clearlyourpriority #1 – if the apphasthis feature, it is alreadyuseful to Antti • Open up, instantlyready for writing • Autosaveenteredtext • Multiplenotescanbesaved • Anysavednotecanbeopenedup for reading • Anysavednotecanbeemailed • Anysavednotecanbedeleted • Bold and italictext • Emailrecipientscanbetakenfrom the addressbook • …
Draft the userinterface • Pen and paperaregood – lowcost, quickiterations • Build a runnableappfromyourdoodlesusing POP • Onlinewireframeappsalsoavailable: Fluid, InDesign • Testyour design with a realuser! • Clickableprototype (POP, Fluid, InDesign) or just flippaperpics • Is yourassumptionabout the needvalid? • Is yourassumptionabout the 1st feature workflowvalid?
Incremental design • Splitnon-trivialfeatures into clearworkflowsteps • Design the simplestpossibleimplementation for eachstep • Thinkhoweachstepcanbeimprovedlater on (ifneeded) • Implement the simplestvariantend-to-end • Nowgotestit with the realuser – what’s the user’spriority, whichstepwouldbenefitmostfrom an improvement? • Does the userbenefitmorefrom an improvement to the existingminimalworkflow, orfrom a new feature?
User storyslicing By Arto Eskelinen,seeslideshare.com
Takeaway • Thinkaboutyourappbeforecodingit • Testyourconcept with a realuser • Paperorwireframeappsaregood for getting feedback • Implementsomethingsimpleend-to-endfirst, addcomplexitylater, whenithasvalue
Key AndroidConcepts • Whatyouneed to knowaboutAndroidappstructure
IntentslaunchActivities • Eachscreen with a userinterface is an Activity • A notewritingscreen, a list of notes, appsettings, … • The user is focused on doing one thing • A component in yourappimplementsone Activity • YourappusuallyhasmultipleActivities (so, alsomultiplecomponents) • Components invokeotherActivitiesusingIntents • Simplypass an Intentobject to startActivity() • Activities in otherappscanalsobeinvoked – for example, viewingwebpagescaninvoke Activity in the browserapp • Yourappcanpublishany Activity itimplements via itsmanifestfile
Non-interactiveactivities • A Service is a component running in the background • Playing music, fetching data, miningbitcoin, etc. • Another component canusebindService() to interact with it • A ContentProvider is a shared data manager • A music library, textnotes, searchresults etc. • Rich API inheritedfrom the ContentProviderclass • A BroadcastReceiverlistens for systemstatechanges • Batterylow, networkconnectionlost, memorylow, etc. • Mayeg. triggerautosave, show an icon in status bar, lock the screen
Declaringpublicactivities This is the applicationmanifest XML file, generatedbyAndroid Studio for you
Declaringyourrequirements Devicesthatdon’tfulfillyourmanifestrequirementscan’teveninstall the appfrom Play Store.
Non-codeelements • Resources = images, view layout, localizationtext, etc. • Storedunder the res/ subdirectory in yourapp • Drawables (= images) in res/drawables/ • Localizedfiles in res/subdirectory-languagecode/ • Youcanprovidedifferentlayouts & images for differentdevicetypes • Provideresourcefilevariants for differentresolutions, aspectratios and localizations • The systemautomaticallychooses the bestmatchingresources
PuttingYourAppTogether • Makingitallwork and run on yourdevice
Getting to the beef • Youhavevalidatedyourappconcept with the user? • Youhavechosenyourfirst feature? • Youhavetestedyourwireframemockup with the user? • Youhavesome idea aboutActivities, Intents, the manifestfile, and resources? • YouhaveinstalledAndroid Studio? • Good: thenlet’sgetback to ”Start a new Project”… let’s click it all together!
Nowyouneed to decidewhichdevicetypes and versions to support…
SeveraltemplateActivitiesareavailable.We’llbuildourownsochooseEmpty!SeveraltemplateActivitiesareavailable.We’llbuildourownsochooseEmpty!
Click on the left at 1:Project to findall the elements of yourapp
The manifestmaps the Launcher’sstart-up action (”MAIN”) to yourMainActivity
Here is the layout object. Select and delete the defaultTextView Nowselectyour layout, the deviceviewappears to the right.
Whendone, press Play! Drag the MultilineTextfrom the widgetpaletteon top of yourRelativeLayoutand resize to fitscreen.
Selecting the device to run on • Ifyouhave a realAndroiddevice • EnableDeveloperMode in the AndroidSettingsapp • In 4.2+, go to Aboutdevice, tapBuildNumber 7 times (really!) • Connect it to your PC/Mac with a USB cable • Select the device from the pop-up that appears after Play • If you don’t • Select emulator, and choose the devicetype to emulate • Note: it’s a good idea to test on alldevicevariantsyouwish to support, soyoumaywant to use the emulator for othertypesevenifyouhavesomerealdevice
The AdhocIdeasapp, 1st priority feature ready for usertesting! Multitasking, limitedautosave, etcprovidedbysystem.
Drag a button to your Layout, giveit a label Resize the UIelements to fit
The editorwill help youadd the imports Write a function to implementdesiredbehavior (e.g. sendemail)
In layout view, select the button, thenselectyour new function as itsonClickeventhandler