L01b-Foundation and Tools
L01b-Foundation and Tools
1
Lecture Overview
•Programs and Operating Systems
• What is Android (for a programmer)?
• Android - Device and Interaction Overview
• Development Tools
Program
Operating Systems
Hardware
3
We program to an API
Program
API
Operating Systems
Hardware
4
API is good - but frameworks are better
Program
Android Frameworks
iOS
API
Operating Systems
Android
Programming languages:
Java,C/C++,Kotlin
• Different culture
14
Some Assumptions (from now on...)
• You know how to build Java programs
• Event handling
• Call-backs
Lecture Overview - Where are we?
•Programs and Operating Systems
•What is Android (for a programmer)?
•Android - Device and Interaction Overview
• Development Tools
• Configuring the IDE for Android Development
Home
20
Back Button
• This will take you back to the previous screen
• R.when
Vasa Personal Note: I miss this button the most
I use the iPhone / iPad)
Back
Menu Button (mainly older models)
• Android
• Android studio
• Debugger is powerful
25
IDE, SDK and Emulator
• IDE - Editor where we write the code
29
Emulator is nice .. but phone is better
• The emulator runs the Android O/S (you can run any
version from 1.6 up)
• Why?
• During development,
• Why?
33
Lets get our feet wet
34
Demo 1
• Run IDE + Create Simple Hello World
• Send it to Emulator
35
Lecture Overview - Where are we?
• Programs and Operating Systems
• Development Tools
37
What is involved?
• Place UI controls (Text and Image)
• Centre text
38
Knowledge Needed to Build it...
• What UI Controls available?
39
Android Offers a number of UI Controls
Progress
These are
a small
subset of
available
controls
40
Each Screen is an Activity
Activity
41
Views are Android’s Key UI Building Block
TextView
ImageView
42
Views are Placed inside a View Group
• Different types of View Groups are provided
View Group
(Linear Layout)
43
View Groups and Layouts
•Android offers the following View Groups,
•Linear Layout (Horizontal or Vertical)
•Absolute Layout (You set X, Y for each View)
•Table Layout (Rows and Columns)
•Relative Layout (Position relative to other Views)
•Frame Layout (Show only one view at a time)
•Scroll View (Permits scrolling of the screen)
•View Groups can be nested
44
Linear Layout
•Two Linear Layouts with 4 Views each
•Nested View Groups
•Activity contains,
•Linear Layout (Vertical)
•Linear Layout (Horizontal)
•Linear Layout (Vertical)
•8 Text Views
Source code:
http://developer.android.com/resources/tutorials/views/hello-linearlayout.html
45
How do we program the Layout?
• Layout can be written as an XML file
47
Demo 3 - Linear Layout Control
49
Generated Code, Layout & Resources
• How did Australia image get into the App.?
50
Resource Definition
51
Resources and Generated Code
A reference to these
gets automatically
generated by the
Android SDK tools
52
Resources and Generated Code
Generated Code
53
A Reference to Layout also Generated
54
Concept Recap
55
How does Activity know about layout?
This is the Activity Class
57
Activity Creation
58
Activity Creation - Layout Rendeing
60
Application Manifest File
Application Icon Reference
View Group
(Layout)
Layout Definition
(main.xml)
62
Layouts and Resources
String constant
64
Layout and String Information
65
String Constant Values
Defined as a
resource
@drawable/bots
67
Significance of hdpi/ldpi/mdpi
68
@ Tag and Multiple Screen
Resolutions
• Dealing with multiple screen resolutions
@drawable/icon
High
Low
Medium
70
Drawable at Multiple Resolutions
• You should ideally provide these images
71
Lecture Overview - Where are we?
• Programs and Operating Systems
• Development Tools
Views
• Log.d(“TAG”, “I am here!”);
76
Log Messages in Android
77
Demo 2
• Logging a message in Android
• What is ProGuard?
• Code optimisation/obfuscation
discuss later...)
tool (we will
• Development Tools
• Common Layouts
• http://developer.android.com/guide/topics/ui/layout-objects.html