Introduction to Android Software Development T-110.5130 Mobile Systems programming Juha-Matti Liukkonen

Embed Size (px)

DESCRIPTION

Introduction to Android World’s most popular mobile operating system

Citation preview

Introduction to Android Software Development T Mobile Systems programming Juha-Matti Liukkonen Introduction to Android Software Development 1. Introduction to Android 2. Development Tools 3. Interlude: The Design Step 4. Key Android Concepts 5. Putting Your App Together 6. Where to go next Introduction to Android Worlds most popular mobile operating system Android = Linux Linux kernel Most Android specific mechanisms now included in mainstream Linux kernel wakelocks, binder, etc Custom startup script mechanism A simple, classic init.rc script solution (Generic) applications written in Java Applications do not need to care about underlying processor capabilities Custom Java runtime (actually 2: Dalvik, Android RunTime) Optimized for low footprint = suitable for mobile devices users In 2015, 82% of new smartphones ran Android 1.4 billion users, 1.5 million new devices activated every day 54% total market share (and obviously rising) 78% of Chinese market 70% of tablet market different device models 400+ device manufacturers Also used in wearables, TVs and cars Small segments so far Most devices are never updated Main versions: W (watch) x x x 2010 Many screen sizes, form factors Also different interaction models! Variety pros & cons Con: your software will not work properly on most Android devices Choose your target devices wisely to reach your targeted users! Customized layouts, graphics, interaction models needed to support different device types Some handled via Play Store device filters, some by app manifest tags, some by resources, some you need to handle in your code Pro: the same programming model works on all Android devices If you know how to create software for an Android phone, you also know how to do it for tablets, smartwatches, cars and TVs Takeaway Android is basically Java on Linux Its easy to reach gazillions of users with Android apps Variety makes it hard to write good Android apps Development Tools What you need to get your app done The good and the bad news Android Studio contains everything you need (yay 2016!) just that it usually doesnt 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 Getting ready to do software Press OK now your environment is set up Android Studio will generate application skeletons for common application types for you All you need to do is fill in the details Now things get interesting What to choose as Activity? What does your software actually need to do? This is the stage when we usually do Interlude: The Design Step The critical step before actually writing any software (nothing to do with Android as such) Understand your use case What problem does your app solve? For whom? (Concrete example, no abstract persons!) In which situation does the problem occur? How does the user launch your app in that situation? How does your app fulfill the users need? Example: Adhoc Ideas Problem: helping ad-hoc ideas be stored (eg. app ideas!) User: my colleague Antti (will use him for testing) Where: in public transport, during work commutes (noisy environment so audio recording isnt polite & doesnt work) Launch: shortcut icon on home screen Fulfillment: its easy to write free-form text immediately Identify & prioritize features 1. Open up, instantly ready for writing 2. Autosave entered text 3. Multiple notes can be saved 4. Any saved note can be opened up for reading 5. Any saved note can beed 6. Any saved note can be deleted 7. Bold and italic text 8.recipients can be taken from the address book 9. This is clearly our priority #1 if the app has this feature, it is already useful to Antti Draft the user interface Pen and paper are good low cost, quick iterations Build a runnable app from your doodles using POP Online wireframe apps also available: Fluid, InDesign Test your design with a real user! Clickable prototype (POP, Fluid, InDesign) or just flip paper pics Is your assumption about the need valid? Is your assumption about the 1st feature workflow valid? Incremental design Split non-trivial features into clear workflow steps Design the simplest possible implementation for each step Think how each step can be improved later on (if needed) Implement the simplest variant end-to-end Now go test it with the real user whats the users priority, which step would benefit most from an improvement? Does the user benefit more from an improvement to the existing minimal workflow, or from a new feature? User story slicing By Arto Eskelinen, see slideshare.com Takeaway Think about your app before coding it Test your concept with a real user Paper or wireframe apps are good for getting feedback Implement something simple end-to-end first, add complexity later, when it has value Key Android Concepts What you need to know about Android app structure Intents launch Activities Each screen with a user interface is an Activity A note writing screen, a list of notes, app settings, The user is focused on doing one thing A component in your app implements one Activity Your app usually has multiple Activities (so, also multiple components) Components invoke other Activities using Intents Simply pass an Intent object to startActivity() Activities in other apps can also be invoked for example, viewing web pages can invoke Activity in the browser app Your app can publish any Activity it implements via its manifest file Non-interactive activities A Service is a component running in the background Playing music, fetching data, mining bitcoin, etc. Another component can use bindService() to interact with it A ContentProvider is a shared data manager A music library, text notes, search results etc. Rich API inherited from the ContentProvider class A BroadcastReceiver listens for system state changes Battery low, network connection lost, memory low, etc. May eg. trigger autosave, show an icon in status bar, lock the screen Declaring public activities This is the application manifest XML file, generated by Android Studio for you Filtering Intents you can serve Declaring your requirements Devices that dont fulfill your manifest requirements cant even install the app from Play Store. Non-code elements Resources = images, view layout, localization text, etc. Stored under the res/ subdirectory in your app Drawables (= images) in res/drawables/ Localized files in res/subdirectory-languagecode/ You can provide different layouts & images for different device types Provide resource file variants for different resolutions, aspect ratios and localizations The system automatically chooses the best matching resources Putting Your App Together Making it all work and run on your device Getting to the beef You have validated your app concept with the user? You have chosen your first feature? You have tested your wireframe mockup with the user? You have some idea about Activities, Intents, the manifest file, and resources? You have installed Android Studio? Good: then lets get back to Start a new Project lets click it all together! Give your app a name here Now you need to decide which device types and versions to support Several template Activities are available. Well build our own so choose Empty! MainActivity is a good name, just click Finish! This skeleton is automatically generated for us Click on the left at 1:Project to find all the elements of your app The manifest maps the Launchers start-up action (MAIN) to your MainActivity Now select your layout, the device view appears to the right. Here is the layout object. Select and delete the default TextView Drag the Multiline Text from the widget palette on top of your RelativeLayout and resize to fit screen. When done, press Play! Selecting the device to run on If you have a real Android device Enable Developer Mode in the Android Settings app In 4.2+, go to About device, tap Build Number 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 dont Select emulator, and choose the device type to emulate Note: its a good idea to test on all device variants you wish to support, so you may want to use the emulator for other types even if you have some real device The Adhoc Ideas app, 1st priority feature ready for user testing! Multitasking, limited autosave, etc provided by system. Drag a button to your Layout, give it a label Resize the UI elements to fit Write a function to implement desired behavior (e.g. send) The editor will help you add the imports In layout view, select the button, then select your new function as its onClick event handler Next steps Adding useful functionality Advertisements!, billing per-typed-letter, Plenty of useful APIs available in Google Services library Making it pretty and natural to use Study the Google Material Design guidelines Add drawable resources to have image backgrounds etc Optimizing UI layout for different device types Create resolution specific layout XML files Remember resolution variants of your drawables Where to go next Where to find additional information First place to visit This is the treasure trove Start from Training or API Guides, also do look at the Design page Developer Reference is where most Android developers spend their days This is where you get to distribute and sell your app via the Play Store! Thank You! Juha-Matti Liukkonen