SlideShare a Scribd company logo
1 of 73
Download to read offline
Android Development
- the basics
Tomáš Kypta
Agenda
• Android platform and ecosystem	

• Android SDK and development tools	

• Hello World	

• building blocks of Android apps & the
manifest file	


• activities, widgets, intents
Agenda
• dialogs, toasts, notifications	

• fragments
Android platform
• Linux-based operating system	

• open-source (http://source.android.com/)	

• originally phone OS	

• tablet support (since Honeycomb, Android
3.0)	


• Google TV
History
• 2003, Android inc.	

• 2005, acquired by Google	

• Sep 2008, the first Android phone	

• T-Mobile G1	

• May 2010, Froyo (Android 2.2)	

• Feb 2011, Honeycomb (Android 3.0)
History
• Oct 2011, Ice Cream Sandwich (Android
4.0)	


• July 2012, Jelly Bean (Android 4.1)	

• July 2013, Jelly Bean (Android 4.3)	

• Oct 2013, KitKat (Android 4.4)
Platform Versions
Android ecosystem
• thousands of devices	

• the most popular mobile platform	

• 1.5 million new devices activated every day	

• September 3, 2013, 1 billion Android
devices have been activated	


• most devices made by Samsung
Google Play
• app can be acquired by app stores	

• Google Play, http://play.google.com	

• other stores	

• > 50 billion apps have been installed from
Google Play	


• July 2013, 1 million apps
Google Play
• purchasing	

• selling	

• Play Music, Play Books, ...
Google Play
• selling apps	

• 15 min return period	

• ads	

• AdMob, ...	

• in-app billing
Android “problems”
• fragmentation	

• manufacturer/carrier enhancements	

• updates & support	

• openness - low quality apps in Google Play	

• malware	

• users
Android security
• app can be installed directly	

• .apk file	

• user accepts app permissions when
installing or updating the app
Android security
• Verify Apps (Android 2.3+)	

• checks every app install	

• Google Play can remotely uninstall harmful
app
Development
• programming in “Java”	

• native apps possible (C++)	

• development tools platform friendly	

• Windows, Linux, Mac OS X
Development
• IDE support	

• Android Studio, IntelliJ IDEA, ADT plugin
for Eclispse, Netbeans	


• you can freely develop on any device
Android SDK
• android - Android SDK and AVD Manager	

• adb - Android Debug Bridge	

• monitor - (ddms & hierarchyviewer)	

• emulator	

• lint, Traceview, ProGuard	

• docs, samples
Libraries
• compatibility libraries	

• v4 - backports lots of newer functionality
to Android 1.6+	


• Google Play In-app Billing
Libraries
• Google Play Services	

• Google Maps	

• Games	

• Google+	

• Authorization
Libraries
• AdMob	

• Google Analytics, Flurry, Crittercism	

• Google Cloud Messaging
Hello World
Build
Android building blocks
• Activity	

• Service	

• Content provider	

• Broadcast receiver	

• AndroidManifest.xml
Activity
• screen with user interface	

• the only visual component	

• example - an email app	

• list of emails	

• details of an email	

• email composition
Service
• has no UI	

• long-running tasks	

• examples	

• music playback service	

• download service	

• sync service
Content Provider
• managers and shares application data	

• data storage doesn’t matter (db, web,
filesystem)	


• apps can query and modify data through
content provider	


• r/w permissions can be defined	

• examples - all system dbs (SMS, contacts, ...)
Broadcast Receiver
• responds to broadcasts	

• broadcasts are system wide	

• can be registered statically or dynamically	

• system or custom messages	

• examples - incoming SMS, incoming call,

screen turned off, low baterry, removed SD
card, BT device available, ...
AndroidManifest.xml
• defines what parts the app have	

• defines which endpoints are exposed	

• minimum/maximum API level	

• permissions	

• declare hardware and software features	

• require configuration
Intent
• asynchronous message	

• binds components together (all except
Content Provider)	


• starting activities	

• starting services and binding to services	

• sending broadcasts
Activity
• a subclass of android.app.Activity	

• app usually has many activities	

• activities managed in activity stack	

• newly started activity is placed on the top
of the stack
Activity Lifecycle
• activity can be in different states during its
lifecycle	


• foreground, visible, stopped, killed	


• when activity state changes a system
callback is called
Activity callbacks
• onCreate() - activity created	

• onStart() - activity visible for the user	

• onResume() - activity gains user focus	

• onPause() - system resuming another
activity	


• onStop() - activity becoming invisible to
the user
Activity callbacks
• onDestroy() - before activity is
destroyed	


• onRestart() - called if activity was

previously stopped, called prior to onStart()
Configuration changes
• when configuration changes, activities are
destroyed and recreated	


• default behaviour, can be changed	


• properly handle config changes	

•

onSaveInstanceState(Bundle)
Intent & Activity
• starting activity explicitly	

•

new Intent(context, MyActivity.class)!

•

new Intent(Intent.ACTION_VIEW, Uri.parse(“http://
developer.android.com”))!

• starting activity implicitly	

• starting activity for result
User Interface
• defined by a hierarchy of views	

• layouts = containers	

•

LinearLayout, RelativeLayout, FrameLayout, ...
User Interface
• widgets	

• UI objects	

• Button, TextView, EditText,
RadioButton, ...	


• WebView
User Interface
• list widgets	

• subclasses of AdapterView	

• display a list of items	

• use adapter to bind list do data	

•

ListView, GridView, Spinner, ...
Resources
• drawables	

• bitmaps	

• 9-patch png	

• state lists	

• layer lists	

• shape drawables
Resources
• layout	

• strings	

• colors	

• menus	

• dimensions	

• animations
Resources
• arrays	

• ids	

• raw	

• xml	

• ...
Screen sizes and
densities
Screen sizes and
densities
• How to handle different screen sizes and
densities?
Resources
• resources can be created in several
versions	


• the best version is selected according to
current device configuration in runtime	


• resource units	

• dp - density-independent pixel	

• sp - scale-independent pixel (for fonts)
Resource qualifiers
• suffixes for resource folders	

• drawables, drawable-mdpi, ...	

• values, values-cs	

• layout, layout-sw640dp	

• drawable-hdpi-v11
Resource qualifiers
• screen density - ldpi, mdpi, hdpi, xhdpi, ...	

• screen size - small, normal, large, xlarge	

• screen orientation - port, land	

• language - en, cs, sk, ...	

• version - v11, v14, ...
Resource qualifiers
• since Android 3.2	

• w<N>dp - available screen width, w600dp	

• h<N>dp - available screen heights, h720dp	

• sw<N>dp - smallest width (does not
change with orientation)
Resources
• accessed from code via generated R.java file
and resource ids	

• view.findViewById(R.id.txt_name)!
• txtName.setText(R.string.txt_name_label)
Android version
fragmentation
• How to handle different API levels available
on different devices?
Android version
fragmentation
• build target	

• API level the app is compiled against	

• AndroidManifest.xml	

•

<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="16" />
Android version
fragmentation
• handling versions in code	

if (Build.VERSION.SDK_INT <
Build.VERSION_CODES.GINGERBREAD) {!
// code for Android < 2.3!
}
Android version
fragmentation
private boolean functionalitySupported = false;!

!
static {!
try {!
checkFunctionalitySupported();!
} catch (NoClassDefFoundError e) {!
!

functionalitySupported = false;!

}!
}!

!
private static void checkFunctionalitySupported() throws !
!

!

!

!

!

!

NoClassDefFoundError {!

!
functionalitySupported = android.app.Fragment.class != null;!
}!
Fragments
• a piece of application UI	

• introduced to support more flexible UI	

• phones and tablets together in one app	

• fragment != activity	

• fragments are used within activities
Fragments
• since Android 3.0	

• support library v4 backports them to
Android 1.6+
Threads
• main thread = UI thread	

• do not ever block the UI thread!!!	

• use worker threads for time consuming
operations	


• UI toolkit not thread safe - never

manipulate UI from a worker thread
Menu
• menu resource	

• Android < 3.0 the whole menu hidden
under menu button	


• ActionBar since Android 3.0	

• items can be displayed in the action bar
Menu
• behaviour for items that don’t fit in the
action bar	


• hidden under menu button (if the device
has one)	


• system overflow icon in the action bar
Dialogs
• floating window screen
Dialogs
• standard dialogs	

• custom dialogs	

• activity with dialog style	

• since fragments used via DialogFragment
Dialogs
• might be tedious to create	

• difficult to style	

• StyledDialogs	

•

https://github.com/inmite/android-styled-dialogs	


• the library makes styling and using dialogs
a piece of cake
Toast
• simple non-modal information	

• displayed for a short period of time	

• doesn’t have user focus
Notifications
• a message that can be displayed to the user
outside your normal UI	


• displayed in notification area
Notifications
• user can open notification drawer to see
the details	


• app can define UI and click action	

•

NotificationCompat.Builder
Preferences
SharedPreferences prefs = PreferenceManager!
.getDefaultSharedPreferences(context);!

!
SharedPreferences prefs =

!

config.getSharedPreferences(PREFS_FILE_NAME,!
Activity.MODE_PRIVATE);!

!
int storedValue = prefs.getInt(SOME_KEY, defaultValue);!

!
SharedPreferences.Editor editor = prefs.edit();!
editor.putInt(SOME_KEY, storedValue);!
editor.commit();
Sources
• developer.android.com	

• android-developers.blogspot.com	

• source.android.com	

• stackoverflow.com	

• youtube.com/androiddevelopers	

• svetandroida.cz
THE END

More Related Content

What's hot

Tehran's 1st Android bootcamp - Part1
Tehran's 1st Android bootcamp - Part1Tehran's 1st Android bootcamp - Part1
Tehran's 1st Android bootcamp - Part1Mohsen Mirhoseini
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development BasicMonir Zzaman
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]Sittiphol Phanvilai
 
Basics of Android
Basics of Android Basics of Android
Basics of Android sabi_123
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Arduino - Android Workshop Presentation
Arduino - Android Workshop PresentationArduino - Android Workshop Presentation
Arduino - Android Workshop PresentationHem Shrestha
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principlesHenk Laracker
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Android Development Workshop
Android Development WorkshopAndroid Development Workshop
Android Development WorkshopPeter Robinett
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectJoemarie Amparo
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersBoom Shukla
 
Android application development
Android application developmentAndroid application development
Android application developmentMadhuprakashR1
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-pptSrijib Roy
 
Introduction to Android, Architecture & Components
Introduction to  Android, Architecture & ComponentsIntroduction to  Android, Architecture & Components
Introduction to Android, Architecture & ComponentsVijay Rastogi
 

What's hot (20)

Android Presentation
Android PresentationAndroid Presentation
Android Presentation
 
Tehran's 1st Android bootcamp - Part1
Tehran's 1st Android bootcamp - Part1Tehran's 1st Android bootcamp - Part1
Tehran's 1st Android bootcamp - Part1
 
Android
AndroidAndroid
Android
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
 
Basics of Android
Basics of Android Basics of Android
Basics of Android
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Arduino - Android Workshop Presentation
Arduino - Android Workshop PresentationArduino - Android Workshop Presentation
Arduino - Android Workshop Presentation
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Android Development Workshop
Android Development WorkshopAndroid Development Workshop
Android Development Workshop
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample Project
 
Android overview
Android overviewAndroid overview
Android overview
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
 
Android application development
Android application developmentAndroid application development
Android application development
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-ppt
 
Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
 
Introduction to Android, Architecture & Components
Introduction to  Android, Architecture & ComponentsIntroduction to  Android, Architecture & Components
Introduction to Android, Architecture & Components
 

Similar to Android development - the basics, MFF UK, 2013

Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1drudolph11
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentCan Elmas
 
Synapseindia android apps application development
Synapseindia android apps application developmentSynapseindia android apps application development
Synapseindia android apps application developmentSynapseindiappsdevelopment
 
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionDuckMa
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions newJoe Jacob
 
Android Workshop_1
Android Workshop_1Android Workshop_1
Android Workshop_1Purvik Rana
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA NITIN GUPTA
 
Android development
Android developmentAndroid development
Android developmentmkpartners
 
Introduction to Android (before 2015)
Introduction to Android (before 2015)Introduction to Android (before 2015)
Introduction to Android (before 2015)Chien-Ming Chou
 
MDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android FrameworkMDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android FrameworkAlexandru Radovici
 
Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android
Don Thorp & Marshall Culpepper: Advanced Titanium Development for AndroidDon Thorp & Marshall Culpepper: Advanced Titanium Development for Android
Don Thorp & Marshall Culpepper: Advanced Titanium Development for AndroidAxway Appcelerator
 

Similar to Android development - the basics, MFF UK, 2013 (20)

Android development first steps
Android development   first stepsAndroid development   first steps
Android development first steps
 
Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android quick talk
Android quick talkAndroid quick talk
Android quick talk
 
android
androidandroid
android
 
Synapseindia android apps application development
Synapseindia android apps application developmentSynapseindia android apps application development
Synapseindia android apps application development
 
Android OS
Android OSAndroid OS
Android OS
 
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions new
 
Android Workshop_1
Android Workshop_1Android Workshop_1
Android Workshop_1
 
Android Presentation
Android PresentationAndroid Presentation
Android Presentation
 
Google android os
Google android osGoogle android os
Google android os
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA
 
Android development
Android developmentAndroid development
Android development
 
Google android os
Google android osGoogle android os
Google android os
 
Android : Deep dive into developing MobileApp using Android
Android : Deep dive into developing MobileApp using AndroidAndroid : Deep dive into developing MobileApp using Android
Android : Deep dive into developing MobileApp using Android
 
Introduction to Android (before 2015)
Introduction to Android (before 2015)Introduction to Android (before 2015)
Introduction to Android (before 2015)
 
MDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android FrameworkMDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android Framework
 
Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android
Don Thorp & Marshall Culpepper: Advanced Titanium Development for AndroidDon Thorp & Marshall Culpepper: Advanced Titanium Development for Android
Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 

More from Tomáš Kypta

Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworksTomáš Kypta
 
Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworksTomáš Kypta
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for AndroidTomáš Kypta
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for AndroidTomáš Kypta
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on AndroidTomáš Kypta
 
Android Develpment vol. 3, MFF UK, 2015
Android Develpment vol. 3, MFF UK, 2015Android Develpment vol. 3, MFF UK, 2015
Android Develpment vol. 3, MFF UK, 2015Tomáš Kypta
 
Writing testable Android apps
Writing testable Android appsWriting testable Android apps
Writing testable Android appsTomáš Kypta
 
Android Develpment vol. 2, MFF UK, 2015
Android Develpment vol. 2, MFF UK, 2015Android Develpment vol. 2, MFF UK, 2015
Android Develpment vol. 2, MFF UK, 2015Tomáš Kypta
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and AndroidTomáš Kypta
 
Android Development for Phone and Tablet
Android Development for Phone and TabletAndroid Development for Phone and Tablet
Android Development for Phone and TabletTomáš Kypta
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on AndroidTomáš Kypta
 
Android Development 201
Android Development 201Android Development 201
Android Development 201Tomáš Kypta
 
Užitečné Android knihovny pro vývoj a testování
Užitečné Android knihovny pro vývoj a testováníUžitečné Android knihovny pro vývoj a testování
Užitečné Android knihovny pro vývoj a testováníTomáš Kypta
 
Programování pro Android - úvod, FI MUNI, 2013
Programování pro Android - úvod, FI MUNI, 2013Programování pro Android - úvod, FI MUNI, 2013
Programování pro Android - úvod, FI MUNI, 2013Tomáš Kypta
 
Stylování ActionBaru
Stylování ActionBaruStylování ActionBaru
Stylování ActionBaruTomáš Kypta
 

More from Tomáš Kypta (18)

Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworks
 
Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworks
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Android Develpment vol. 3, MFF UK, 2015
Android Develpment vol. 3, MFF UK, 2015Android Develpment vol. 3, MFF UK, 2015
Android Develpment vol. 3, MFF UK, 2015
 
Writing testable Android apps
Writing testable Android appsWriting testable Android apps
Writing testable Android apps
 
Android Develpment vol. 2, MFF UK, 2015
Android Develpment vol. 2, MFF UK, 2015Android Develpment vol. 2, MFF UK, 2015
Android Develpment vol. 2, MFF UK, 2015
 
ProGuard
ProGuardProGuard
ProGuard
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and Android
 
Android Development for Phone and Tablet
Android Development for Phone and TabletAndroid Development for Phone and Tablet
Android Development for Phone and Tablet
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Android Libraries
Android LibrariesAndroid Libraries
Android Libraries
 
Android Development 201
Android Development 201Android Development 201
Android Development 201
 
Užitečné Android knihovny pro vývoj a testování
Užitečné Android knihovny pro vývoj a testováníUžitečné Android knihovny pro vývoj a testování
Užitečné Android knihovny pro vývoj a testování
 
Programování pro Android - úvod, FI MUNI, 2013
Programování pro Android - úvod, FI MUNI, 2013Programování pro Android - úvod, FI MUNI, 2013
Programování pro Android - úvod, FI MUNI, 2013
 
Stylování ActionBaru
Stylování ActionBaruStylování ActionBaru
Stylování ActionBaru
 

Recently uploaded

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 

Recently uploaded (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 

Android development - the basics, MFF UK, 2013

  • 1. Android Development - the basics Tomáš Kypta
  • 2. Agenda • Android platform and ecosystem • Android SDK and development tools • Hello World • building blocks of Android apps & the manifest file • activities, widgets, intents
  • 3. Agenda • dialogs, toasts, notifications • fragments
  • 4. Android platform • Linux-based operating system • open-source (http://source.android.com/) • originally phone OS • tablet support (since Honeycomb, Android 3.0) • Google TV
  • 5. History • 2003, Android inc. • 2005, acquired by Google • Sep 2008, the first Android phone • T-Mobile G1 • May 2010, Froyo (Android 2.2) • Feb 2011, Honeycomb (Android 3.0)
  • 6. History • Oct 2011, Ice Cream Sandwich (Android 4.0) • July 2012, Jelly Bean (Android 4.1) • July 2013, Jelly Bean (Android 4.3) • Oct 2013, KitKat (Android 4.4)
  • 8. Android ecosystem • thousands of devices • the most popular mobile platform • 1.5 million new devices activated every day • September 3, 2013, 1 billion Android devices have been activated • most devices made by Samsung
  • 9. Google Play • app can be acquired by app stores • Google Play, http://play.google.com • other stores • > 50 billion apps have been installed from Google Play • July 2013, 1 million apps
  • 10. Google Play • purchasing • selling • Play Music, Play Books, ...
  • 11. Google Play • selling apps • 15 min return period • ads • AdMob, ... • in-app billing
  • 12. Android “problems” • fragmentation • manufacturer/carrier enhancements • updates & support • openness - low quality apps in Google Play • malware • users
  • 13. Android security • app can be installed directly • .apk file • user accepts app permissions when installing or updating the app
  • 14. Android security • Verify Apps (Android 2.3+) • checks every app install • Google Play can remotely uninstall harmful app
  • 15.
  • 16.
  • 17. Development • programming in “Java” • native apps possible (C++) • development tools platform friendly • Windows, Linux, Mac OS X
  • 18. Development • IDE support • Android Studio, IntelliJ IDEA, ADT plugin for Eclispse, Netbeans • you can freely develop on any device
  • 19. Android SDK • android - Android SDK and AVD Manager • adb - Android Debug Bridge • monitor - (ddms & hierarchyviewer) • emulator • lint, Traceview, ProGuard • docs, samples
  • 20. Libraries • compatibility libraries • v4 - backports lots of newer functionality to Android 1.6+ • Google Play In-app Billing
  • 21. Libraries • Google Play Services • Google Maps • Games • Google+ • Authorization
  • 22. Libraries • AdMob • Google Analytics, Flurry, Crittercism • Google Cloud Messaging
  • 23.
  • 25. Build
  • 26.
  • 27.
  • 28. Android building blocks • Activity • Service • Content provider • Broadcast receiver • AndroidManifest.xml
  • 29. Activity • screen with user interface • the only visual component • example - an email app • list of emails • details of an email • email composition
  • 30. Service • has no UI • long-running tasks • examples • music playback service • download service • sync service
  • 31. Content Provider • managers and shares application data • data storage doesn’t matter (db, web, filesystem) • apps can query and modify data through content provider • r/w permissions can be defined • examples - all system dbs (SMS, contacts, ...)
  • 32. Broadcast Receiver • responds to broadcasts • broadcasts are system wide • can be registered statically or dynamically • system or custom messages • examples - incoming SMS, incoming call, screen turned off, low baterry, removed SD card, BT device available, ...
  • 33. AndroidManifest.xml • defines what parts the app have • defines which endpoints are exposed • minimum/maximum API level • permissions • declare hardware and software features • require configuration
  • 34. Intent • asynchronous message • binds components together (all except Content Provider) • starting activities • starting services and binding to services • sending broadcasts
  • 35. Activity • a subclass of android.app.Activity • app usually has many activities • activities managed in activity stack • newly started activity is placed on the top of the stack
  • 36. Activity Lifecycle • activity can be in different states during its lifecycle • foreground, visible, stopped, killed • when activity state changes a system callback is called
  • 37. Activity callbacks • onCreate() - activity created • onStart() - activity visible for the user • onResume() - activity gains user focus • onPause() - system resuming another activity • onStop() - activity becoming invisible to the user
  • 38. Activity callbacks • onDestroy() - before activity is destroyed • onRestart() - called if activity was previously stopped, called prior to onStart()
  • 39.
  • 40.
  • 41. Configuration changes • when configuration changes, activities are destroyed and recreated • default behaviour, can be changed • properly handle config changes • onSaveInstanceState(Bundle)
  • 42. Intent & Activity • starting activity explicitly • new Intent(context, MyActivity.class)! • new Intent(Intent.ACTION_VIEW, Uri.parse(“http:// developer.android.com”))! • starting activity implicitly • starting activity for result
  • 43. User Interface • defined by a hierarchy of views • layouts = containers • LinearLayout, RelativeLayout, FrameLayout, ...
  • 44. User Interface • widgets • UI objects • Button, TextView, EditText, RadioButton, ... • WebView
  • 45. User Interface • list widgets • subclasses of AdapterView • display a list of items • use adapter to bind list do data • ListView, GridView, Spinner, ...
  • 46. Resources • drawables • bitmaps • 9-patch png • state lists • layer lists • shape drawables
  • 47. Resources • layout • strings • colors • menus • dimensions • animations
  • 48. Resources • arrays • ids • raw • xml • ...
  • 50. Screen sizes and densities • How to handle different screen sizes and densities?
  • 51. Resources • resources can be created in several versions • the best version is selected according to current device configuration in runtime • resource units • dp - density-independent pixel • sp - scale-independent pixel (for fonts)
  • 52. Resource qualifiers • suffixes for resource folders • drawables, drawable-mdpi, ... • values, values-cs • layout, layout-sw640dp • drawable-hdpi-v11
  • 53. Resource qualifiers • screen density - ldpi, mdpi, hdpi, xhdpi, ... • screen size - small, normal, large, xlarge • screen orientation - port, land • language - en, cs, sk, ... • version - v11, v14, ...
  • 54. Resource qualifiers • since Android 3.2 • w<N>dp - available screen width, w600dp • h<N>dp - available screen heights, h720dp • sw<N>dp - smallest width (does not change with orientation)
  • 55. Resources • accessed from code via generated R.java file and resource ids • view.findViewById(R.id.txt_name)! • txtName.setText(R.string.txt_name_label)
  • 56. Android version fragmentation • How to handle different API levels available on different devices?
  • 57. Android version fragmentation • build target • API level the app is compiled against • AndroidManifest.xml • <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
  • 58. Android version fragmentation • handling versions in code if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {! // code for Android < 2.3! }
  • 59. Android version fragmentation private boolean functionalitySupported = false;! ! static {! try {! checkFunctionalitySupported();! } catch (NoClassDefFoundError e) {! ! functionalitySupported = false;! }! }! ! private static void checkFunctionalitySupported() throws ! ! ! ! ! ! ! NoClassDefFoundError {! ! functionalitySupported = android.app.Fragment.class != null;! }!
  • 60. Fragments • a piece of application UI • introduced to support more flexible UI • phones and tablets together in one app • fragment != activity • fragments are used within activities
  • 61. Fragments • since Android 3.0 • support library v4 backports them to Android 1.6+
  • 62. Threads • main thread = UI thread • do not ever block the UI thread!!! • use worker threads for time consuming operations • UI toolkit not thread safe - never manipulate UI from a worker thread
  • 63. Menu • menu resource • Android < 3.0 the whole menu hidden under menu button • ActionBar since Android 3.0 • items can be displayed in the action bar
  • 64. Menu • behaviour for items that don’t fit in the action bar • hidden under menu button (if the device has one) • system overflow icon in the action bar
  • 66. Dialogs • standard dialogs • custom dialogs • activity with dialog style • since fragments used via DialogFragment
  • 67. Dialogs • might be tedious to create • difficult to style • StyledDialogs • https://github.com/inmite/android-styled-dialogs • the library makes styling and using dialogs a piece of cake
  • 68. Toast • simple non-modal information • displayed for a short period of time • doesn’t have user focus
  • 69. Notifications • a message that can be displayed to the user outside your normal UI • displayed in notification area
  • 70. Notifications • user can open notification drawer to see the details • app can define UI and click action • NotificationCompat.Builder
  • 71. Preferences SharedPreferences prefs = PreferenceManager! .getDefaultSharedPreferences(context);! ! SharedPreferences prefs = ! config.getSharedPreferences(PREFS_FILE_NAME,! Activity.MODE_PRIVATE);! ! int storedValue = prefs.getInt(SOME_KEY, defaultValue);! ! SharedPreferences.Editor editor = prefs.edit();! editor.putInt(SOME_KEY, storedValue);! editor.commit();
  • 72. Sources • developer.android.com • android-developers.blogspot.com • source.android.com • stackoverflow.com • youtube.com/androiddevelopers • svetandroida.cz