Android development first steps
- 4. Agenda
• Working as an Android
Engineer in London
• What is Android
• Think "mobile"
• Tools in Android Development
• Android Development lifecycle
• Basic components
• Acitivity lifecycle - demo
• My first app
- 5. Working as an Android
Engineer in London
• Opportunities
• Big tech companies: Google,
Amazon, Facebook, Yahoo, (Apple?)
etc
• Start ups (SwiftKey, CityMapper,
Busuu)
• Finance, Games, Enterprise etc
• Interview process: Algorithms, Data
structures, Design patterns, Android
framework, Java
• Salary expectations 25k - 90k (£1,673 -
£4,960)
• Big events, conferences, many
meetups, interesting people, startup
spirit
- 6. Android History
• Android, Inc. was founded in Palo Alto, California in
October 2003, by Andy Rubin, Rich Miner, Nick Sears
and Chris White.
• Android was intended for digital cameras.
• Google acquired Android Inc. on August 17, 2005.
• At Google, the team led by Rubin developed a mobile
device platform powered by the Linux kernel.
- 8. Android is a software stack
• Linux Kernel - low level tasks
• Libraries in C C++ (e.g. sqlite) and Android runtime (e.g.
Android virtual machines, Dalvik and more recently ART.
• Application Framework - Your apps run within its own
instance of the VM using the classes and services
provided here.
• Applications - Includes your app and all apps installed on
the device.
- 18. Lollipop
• Material design: fluid,
purposeful motion
• Notifications: respond directly
from your lock screen.
• Battery: feature that extends
your device by up to 90
minutes
• More ways to secure your
device: multiple user accounts,
guest mode, android smart
lock.
• Even more devices: phones,
tablets, wear, tv, auto, one.
- 20. Start thinking like a mobile developer.
• Object Oriented Programming (OOP)
• Java
• Smartphones = small computers
• User Experience (UX) is very important.
• Mobile OS is an ecosystem of many Apps
- 21. Key mobile challenges
• Low processing power
• Limited RAM
• Intermittent, low bandwidth, high latency data
connections
• Impact on battery
• (Android?) Fragmentation
• Support multiple devices
- 25. What happens when you run an app in Android
Studio?
Android
Project
Build Resources
Manifest
Byte Code
Sign
Install
on
device
n
- 26. Tools used in Android development.
• Android Studio
• Gradle
• Genymotion
• SDK Tools
• Version control system (git)
• Continuous Integration tools (Jenkins)
- 33. Gradle
• From command line to Ide to continuous integration
• Declare and execute all tasks necessary to compile, test,
package and ship.
• Support multi-language, multi-platform, multi-project and
multi-channel software, Saas and mobile apps
- 35. A faster Android
emulator
Genymotion is the next generation
of the AndroVM open source
project, already trusted by
2,500,000 developers. It’s even
easier to use and offers lots more
features.
- 36. Android SDK Tools
adb
android
AVD Manager
bmgr
Device Monitor
dmtracedump
Draw 9-Patch
Emulator
etc1tool
hprof-conv
jobb
lint
logcat
mksdcard
ProGuard SDK Manager
Tracer for OpenGL ES
Traceview
zipalign
- 41. Git
• Git is a free and open source
distributed version control
system designed to handle
everything from small to very
large projects with speed and
efficiency.
• UI client for git -> SourceTree
• The Gitflow Workflow defines a
strict branching model
designed around the project
release.
- 44. –Manifesto for Agile Software Development
“Customer Collaboration over Contract
negotiation”
“Working Software over Comprehensive
Documentation”
“Individuals and Interactions over
Processes and tools”
“Responding to change over Following a
plan”
- 45. Basic Android Components
Activities
An Activity represents a single screen with a user
interface
Services
A service is a component that runs in the
background to perform long-running operations or
to perform work for remote processes.
Content
Providers
A content provider manages a shared set of app
data.
Broadcast
Receivers
A Broadcast receiver is a component that responds
to system-wide broadcast announcements.
- 46. The Manifest File
• Android system must know that the component exists by
reading the app’s AndroidManifest.xml file.
• Identify any user permissions the app requires.
• Declare the minimum API level required by the app.
• Declare hardware and software features used or required by
the app (e.g. camera, bluetooth services).
• Other than Android framework APIs (Google maps library).
• And more.
- 48. Views and ViewGroups
• A View is the basic UI component.
• Buttons, TextViews, ImageViews and other are all subclasses of
View.
• ViewGroup is also subclass of a View, and can contain many views.
• Layouts are subclasses of ViewGroup ( LinearLayout, RelativeLayout,
FrameLayout).
• To convert Layouts to Java objects we need to inflate the layout.
• To use our views in Java we need to find the views after inflating the
layout which contains them.
- 58. Activity Lifecycle
• onPause()
• Now the activity is partial
visible! This is a technical term
and means that the activity is
on Pause() because a dialog is
shown. The user cannot
interact with the UI of our
activity anymore.
- 60. Activity lifecycle states
• Entire Lifetime: This is the lifetime between the first call to the
onCreate() and the final call to onDestroy() method. We create all
global resources such as screen layout, global variables etc in
onCreate() and release all resources with onDestroy() call.
• Visible Lifetime: It is the lifetime of an Activity between onStart()
and onStop() method calls. In this the Activity is visible to the user
and he may or may not be able to interact with it. During the visible
lifetime, an Activity maintains its state intact.
• Foreground Lifetime: Foreground lifetime starts with onResume()
and ends with onPause() method calls. During this, the Activity is
completely visible to the user and is on top of all other Activities so
that user can interact with it.
- 62. My first Android App
• Collect requirements
• Start development process
• Test
• Iterate again until the app is
ready for release.
• Maintain the app and add new
features using the previous
steps.
- 64. Break the project into
small user stories
• As a user I want an android
app.
• As a user I want the app to
show images from london.
• As a user I want the images to
be shown in a list view.
• As a user I want the listview to
support infinite images and
scroll smoothly.
• As a user I want to tap on an
image and show it in full
screen.
- 65. Analyse requirements
• Which components do we need?
• 2 screens -> 2 Activities
• 2 screens + 1 imageItem -> 3
Layouts
• List of images -> RecyclerView
• Show data in list -> Adapter
• Items of images -> ViewHolder
• Load images from Internet ->
Picasso
START CODING!!!
- 66. ScrollView
<?xml version="1.0" encoding=“utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/
apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/item_image_imageView"
android:layout_width="match_parent"
android:layout_height="@dimen/image_size"
android:scaleType="centerCrop" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/image_size"
android:scaleType="centerCrop" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/image_size"
android:scaleType="centerCrop" />
.
.
.
</LinearLayout>
</ScrollView>
- 67. If you have 100 images in
the list and can fit 3 items
on screen at once - what is
the minimum number of
views you need to create to
scroll through the list?
1. one
2. three
3. four
4. five
5. ten
6. one hundred
- 68. ListView
• Request a view for every visible
item.
• Create two more for both
directions ( up/down) to avoid
flickering of the screen as a
new view is created and
populated.
• As you scroll more views are
added to memory
- 69. RecyclerView
• Request a view for every visible
item.
• Create two more for both
directions ( up/down) to avoid
flickering of the screen as a new
view is created and populated.
• As you scroll, the views going
off the screen are recycled and
reused for the new views, by
just populating the new data.
• Less memory overhead,
smoother scrolling and less
view management.
- 70. Useful links
• Speakers linkedn profile: https://uk.linkedin.com/pub/
christoforos-nalmpantis/44/231/23
• Activity lifecycle demo source code: https://github.com/
ChristoferNal/activityLifecycle
• PracticeRecyclerVIew source code: https://github.com/
ChristoferNal/practiceRecyclerView/tree/develop