Android Development Crash Course Campus Sundsvall, 2015 Stefan Forsström Department of Information and Communication Systems Mid Sweden University, Sundsvall, Sweden
OVERVIEW The Android Platform Start Programming Applications Example Application Laboration Reference Material 2
The Android platform
THE ANDROID PLATFORM An operating system aimed for Smartphones But also: Tablets, TV s, Sensor motes, Gaming consoles, Watches, etc. Programming Languages Java with Android extensions To code the functionality XML with graphical editor For designing the user interface 4
THE ANDROID PLATFORM Why choose Android? The basics are the same for all different platforms So if you know Android, the change to ios, Windows Phone, etc. is simple But we choose Android because It s free and open source! Just download and start coding It s the most widespread! With over 900 million devices worldwide It s in Java! Which is one of the most popular programming languages It s easy to publish! Register as a developer and publish right away 5
Programming Applications
DOCUMENTATION Most of it is accessible online http://developer.android.com/ Design Esthetic guidelines Develop Programming oriented Distribute Publishing process 7
INSTALLATION AND SETUP If you want to develop Android apps on your own laptop Download Java JDK and run installer http://www.oracle.com/technetwork/java/javase/downloads/index.html Install Android Studio with SDK Download and install http://developer.android.com/sdk/index.html And then you are ready to code! Start Android Studio 8
PROGRAMMING IN ANDROID STUDIO Java Code XML Design XML Code 9
Example Application
EXAMPLE Android XML Layout res/layout/main.xml TextView ImageView 3 Buttons 11
EXAMPLE Java Code src/mainactivity.java Register Listeners Handle OnClick Switch Button Id Change Image 12
EXAMPLE You now have a very simple Cute Kittens app! The laboration will be to extend this app 13
Reference Material
ANDROID COMPONENTS Activities An app can consists of many activities Can be seen as the different screens of an app Start Activity, Game Activity, HighScoreActivity, etc. Views The stuff you see on the screen and can interact with ImageView, TextView, Button, etc. Layouts Used for placing out views on the screen at a specific place LinearLayout, RelativeLayout, TableLayout, etc. Intents Inform the OS on intentions to perform a specific task Start new activity, etc. 15
ACTIVITIES Activities form a flow chart of the application They are stored in the form of a stack With the main activity at the bottom and the current activity on top 16
THE USER INTERFACE User Interface Specified in an XML file Can be seen as a blueprint for the user interface Specifies what views should be seen and where they should appear But Android creates the components at run-time When the XML file is parsed and interpreted 17
VIEWS Views Are the components you see on the screen Each View can be given a unique ID One must find them, to make interaction from the code FindViewById 18
LAYOUTS Layouts Used for positioning Views on the screen Where and what something should be placed The most common Layouts LinearLayout Horizontal or Vertical order of Views FrameLayout A stack of views, from the bottom up RelativeLayout View locations are specified in relation to each other, below, to the right of, etc. TableLayout Views are placed in a table, using row, columns, etc. 19
INTENTS Intents are used to make the Android OS do stuff for you Typical example, start new activity The share intent Probably the easiest way to share via social networks 20
MANIFEST The Android Manifest A configuration file for your whole application Examples The activities that exists within the application All activates must be listed Which activity to call when the app is started The main activity Overall graphical style Icon, Style, Theme, orientation, etc. Security permissions Internet, contacts, phone status, etc. 21
LISTENERS Listeners are used everywhere in Android Because they are a standardized way of coding event handling Used for Buttons, Touches, etc. Example: 22
MEDIA PLAYER Android has a multimedia framework With support for playing most common media types You can play media files as resources (raw resources) Located in the app res/raw folder Or from an URL, streaming over the Internet 23
Contact Dr. Stefan Forsström E-Mail: stefan.forsstrom@miun.se