SlideShare ist ein Scribd-Unternehmen logo
1 von 69
Downloaden Sie, um offline zu lesen
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" 
• toasts
Android platform 
• Linux-based operating system" 
• open-source (http://source.android.com/)" 
• originally phone OS" 
• tablet support (since Honeycomb, Android 
3.0)
Android platform 
• Google TV" 
• Google Glass" 
• Google Wear
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)" 
• June 2014, Android L (developer preview)
Platform Versions
Android ecosystem 
• thousands of devices" 
• the most popular mobile platform" 
• 1.5 million new devices activated every day" 
– Q2 2013" 
• September 3, 2013, 1 billion Android 
devices have been activated" 
• most devices made by Samsung " 
– 65%, Feb 2014
Google Play 
• apps are distributed by app stores" 
– Google Play, http://play.google.com" 
– other stores (Amazon, Samsung, …)" 
• > 50 billion apps have been installed from 
Google Play" 
• > 1.3 million apps
Google Play 
• customers can purchase" 
• developers can sell" 
• Play Music " 
• Play Books " 
• Play Movies
Monetization 
• selling apps" 
– 15 min return period" 
• in-app billing" 
– freemium model" 
• ads" 
– AdMob, ...
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 
apps
Development 
• programming in “Java”" 
– Java SE 7 (KitKat)" 
• native apps possible (C++)" 
• development tools platform friendly" 
– Windows, Linux, Mac OS X
Development 
• IDE support" 
– Android Studio, IntelliJ IDEA" 
– ADT plugin for Eclipse" 
– 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
Support Libraries 
• compatibility libraries" 
– v4 - backports lots of newer functionality 
to Android 1.6+" 
– Fragments, NotificationCompat, ViewPager" 
– v7" 
– AppCompat" 
– v8" 
– v13
Google Play Services 
• Google Maps" 
• In-app Billing" 
• Games" 
• Google+" 
• Authorization
Libraries 
• AdMob" 
• Google Analytics, Flurry, Crittercism
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
Hello World
Build
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
Activity callbacks 
• onPause() - system resuming another 
activity" 
• onStop() - activity becoming invisible to the 
user" 
• onDestroy() - before activity is destroyed
Activity callbacks 
• 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)! 
• starting activity implicitly" 
– new Intent(Intent.ACTION_VIEW, 
Uri.parse(“http://developer.android.com”))! 
• 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, ...
Adapters 
• provide data for Adapter views" 
• are responsible for the creation of items
Resources 
• drawables" 
– bitmaps" 
– 9-patch png" 
– state lists" 
– layer lists" 
– shape drawables
• layout" 
• strings" 
• colors" 
• menus" 
• dimensions" 
• animations 
Resources
• arrays" 
• ids" 
• raw" 
• xml" 
• ... 
Resources
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
Resources 
• resource units" 
– dp - density-independent pixel" 
– sp - scale-independent pixel (for fonts)" 
– never use px!!!
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, en-rGB…" 
• 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)
Localization?
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;! 
}!
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
Logging 
• java.util.logging.Logger 
• android.util.Log
Toast 
• simple non-modal information" 
• displayed for a short period of time" 
• doesn’t have user focus
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

Weitere ähnliche Inhalte

Was ist angesagt?

Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
Henk Laracker
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
Boom Shukla
 

Was ist angesagt? (20)

Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
 
Android Presentation
Android PresentationAndroid Presentation
Android Presentation
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
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 overview
Android overviewAndroid overview
Android overview
 
Arduino - Android Workshop Presentation
Arduino - Android Workshop PresentationArduino - Android Workshop Presentation
Arduino - Android Workshop Presentation
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
Introduction to Android, Architecture & Components
Introduction to  Android, Architecture & ComponentsIntroduction to  Android, Architecture & Components
Introduction to Android, Architecture & Components
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
 
PPT Companion to Android
PPT Companion to AndroidPPT Companion to Android
PPT Companion to Android
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
Android 101 - Introduction to Android Development
Android 101 - Introduction to Android DevelopmentAndroid 101 - Introduction to Android Development
Android 101 - Introduction to Android Development
 
Android Programming Seminar
Android Programming SeminarAndroid Programming Seminar
Android Programming Seminar
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android Presentation [Final]
Android Presentation [Final]Android Presentation [Final]
Android Presentation [Final]
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-ppt
 

Andere mochten auch

Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
Anton Narusberg
 
Mapping with Android
Mapping with AndroidMapping with Android
Mapping with Android
vgrigoruk
 
A review of current routing protocols for ad hoc mobile wireless networks
A review of current routing protocols for ad hoc mobile wireless networksA review of current routing protocols for ad hoc mobile wireless networks
A review of current routing protocols for ad hoc mobile wireless networks
Priyanka Gurnani
 

Andere mochten auch (20)

Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The Basics
 
Android development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWangAndroid development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWang
 
Android ppt
Android ppt Android ppt
Android ppt
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
10 steps to build a business case
10 steps to build a business case10 steps to build a business case
10 steps to build a business case
 
Android Basic Development Day 1 Introduction & ADT
Android Basic Development Day 1 Introduction & ADTAndroid Basic Development Day 1 Introduction & ADT
Android Basic Development Day 1 Introduction & ADT
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android
 
EA Navigator - Enterprise Architecture
EA Navigator - Enterprise ArchitectureEA Navigator - Enterprise Architecture
EA Navigator - Enterprise Architecture
 
Zywall Usg300 User Aware Access Control
Zywall Usg300 User Aware Access ControlZywall Usg300 User Aware Access Control
Zywall Usg300 User Aware Access Control
 
Ofdm Detection on Umts Utra-Fdd up-Link and Implementation of the Modulator/ ...
Ofdm Detection on Umts Utra-Fdd up-Link and Implementation of the Modulator/ ...Ofdm Detection on Umts Utra-Fdd up-Link and Implementation of the Modulator/ ...
Ofdm Detection on Umts Utra-Fdd up-Link and Implementation of the Modulator/ ...
 
Moto v551
Moto v551Moto v551
Moto v551
 
Hierarchical and Hash-based Naming Scheme for Vehicular Information Centric N...
Hierarchical and Hash-based Naming Scheme for Vehicular Information Centric N...Hierarchical and Hash-based Naming Scheme for Vehicular Information Centric N...
Hierarchical and Hash-based Naming Scheme for Vehicular Information Centric N...
 
User mobility and location management
User mobility and location managementUser mobility and location management
User mobility and location management
 
Mapping with Android
Mapping with AndroidMapping with Android
Mapping with Android
 
A review of current routing protocols for ad hoc mobile wireless networks
A review of current routing protocols for ad hoc mobile wireless networksA review of current routing protocols for ad hoc mobile wireless networks
A review of current routing protocols for ad hoc mobile wireless networks
 
Intro To Gsm Wh080917
Intro To Gsm Wh080917Intro To Gsm Wh080917
Intro To Gsm Wh080917
 
Bluetooth1
Bluetooth1Bluetooth1
Bluetooth1
 
Cryptographic Data Splitting and Cloud Computing
Cryptographic Data Splitting and Cloud ComputingCryptographic Data Splitting and Cloud Computing
Cryptographic Data Splitting and Cloud Computing
 
Will the shift from fleet to mobility management revolutionise the leasing in...
Will the shift from fleet to mobility management revolutionise the leasing in...Will the shift from fleet to mobility management revolutionise the leasing in...
Will the shift from fleet to mobility management revolutionise the leasing in...
 
Mobile Video Advertisement
Mobile Video AdvertisementMobile Video Advertisement
Mobile Video Advertisement
 

Ähnlich wie Android development - the basics, MFF UK, 2014

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
DuckMa
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
aswapnal
 

Ähnlich wie Android development - the basics, MFF UK, 2014 (20)

Android development first steps
Android development   first stepsAndroid development   first steps
Android development first steps
 
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
 
初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
 
Pretty 'Awesome' apps (demo at Mobilise Meetup)
Pretty 'Awesome' apps (demo at Mobilise Meetup)Pretty 'Awesome' apps (demo at Mobilise Meetup)
Pretty 'Awesome' apps (demo at Mobilise Meetup)
 
CNIT 128 6. Analyzing Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 1)CNIT 128 6. Analyzing Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 1)
 
Android app development
Android app developmentAndroid app development
Android app development
 
Introduction to Android Development and Security
Introduction to Android Development and SecurityIntroduction to Android Development and Security
Introduction to Android Development and Security
 
PLAT-18 Alfresco iOS Mobile Application Details and Design
PLAT-18 Alfresco iOS Mobile Application Details and DesignPLAT-18 Alfresco iOS Mobile Application Details and Design
PLAT-18 Alfresco iOS Mobile Application Details and Design
 
265.ppt
265.ppt265.ppt
265.ppt
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android Workshop_1
Android Workshop_1Android Workshop_1
Android Workshop_1
 
Introduction to Android (before 2015)
Introduction to Android (before 2015)Introduction to Android (before 2015)
Introduction to Android (before 2015)
 
Synapseindia android apps application development
Synapseindia android apps application developmentSynapseindia android apps application development
Synapseindia android apps application development
 
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
 
Android application development for TresmaxAsia
Android application development for TresmaxAsiaAndroid application development for TresmaxAsia
Android application development for TresmaxAsia
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 

Mehr von Tomáš Kypta

Mehr von 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
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Android development - the basics, MFF UK, 2014

  • 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" • toasts
  • 3. Android platform • Linux-based operating system" • open-source (http://source.android.com/)" • originally phone OS" • tablet support (since Honeycomb, Android 3.0)
  • 4. Android platform • Google TV" • Google Glass" • Google Wear
  • 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)" • June 2014, Android L (developer preview)
  • 8. Android ecosystem • thousands of devices" • the most popular mobile platform" • 1.5 million new devices activated every day" – Q2 2013" • September 3, 2013, 1 billion Android devices have been activated" • most devices made by Samsung " – 65%, Feb 2014
  • 9. Google Play • apps are distributed by app stores" – Google Play, http://play.google.com" – other stores (Amazon, Samsung, …)" • > 50 billion apps have been installed from Google Play" • > 1.3 million apps
  • 10. Google Play • customers can purchase" • developers can sell" • Play Music " • Play Books " • Play Movies
  • 11. Monetization • selling apps" – 15 min return period" • in-app billing" – freemium model" • ads" – AdMob, ...
  • 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 apps
  • 15.
  • 16.
  • 17. Development • programming in “Java”" – Java SE 7 (KitKat)" • native apps possible (C++)" • development tools platform friendly" – Windows, Linux, Mac OS X
  • 18. Development • IDE support" – Android Studio, IntelliJ IDEA" – ADT plugin for Eclipse" – 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. Support Libraries • compatibility libraries" – v4 - backports lots of newer functionality to Android 1.6+" – Fragments, NotificationCompat, ViewPager" – v7" – AppCompat" – v8" – v13
  • 21. Google Play Services • Google Maps" • In-app Billing" • Games" • Google+" • Authorization
  • 22. Libraries • AdMob" • Google Analytics, Flurry, Crittercism
  • 23.
  • 24. Android building blocks • Activity" • Service" • Content provider" • Broadcast receiver" • AndroidManifest.xml
  • 25. Activity • screen with user interface" • the only visual component" • example - an email app" – list of emails" – details of an email" – email composition
  • 26. Service • has no UI" • long-running tasks" • examples" – music playback service" – download service" – sync service
  • 27. 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, ...)
  • 28. 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, ...
  • 29. 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
  • 30. Intent • asynchronous message" • binds components together (all except Content Provider)" • starting activities" • starting services and binding to services" • sending broadcasts
  • 32. Build
  • 33.
  • 34.
  • 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
  • 38. Activity callbacks • onPause() - system resuming another activity" • onStop() - activity becoming invisible to the user" • onDestroy() - before activity is destroyed
  • 39. Activity callbacks • onRestart() - called if activity was previously stopped, called prior to onStart()
  • 40.
  • 41.
  • 42. Configuration changes • when configuration changes, activities are destroyed and recreated" – default behaviour, can be changed" • properly handle config changes" – onSaveInstanceState(Bundle)
  • 43. Intent & Activity • starting activity explicitly" – new Intent(context, MyActivity.class)! • starting activity implicitly" – new Intent(Intent.ACTION_VIEW, Uri.parse(“http://developer.android.com”))! • starting activity for result
  • 44. User Interface • defined by a hierarchy of views" • layouts = containers" – LinearLayout, RelativeLayout, FrameLayout, ...
  • 45. User Interface • widgets" – UI objects" – Button, TextView, EditText, RadioButton, ..." – WebView
  • 46. User Interface • list widgets" – subclasses of AdapterView" – display a list of items" – use adapter to bind list do data" – ListView, GridView, Spinner, ...
  • 47. Adapters • provide data for Adapter views" • are responsible for the creation of items
  • 48. Resources • drawables" – bitmaps" – 9-patch png" – state lists" – layer lists" – shape drawables
  • 49. • layout" • strings" • colors" • menus" • dimensions" • animations Resources
  • 50. • arrays" • ids" • raw" • xml" • ... Resources
  • 51. Screen sizes and densities
  • 52. Screen sizes and densities • How to handle different screen sizes and densities?
  • 53. Resources • resources can be created in several versions" – the best version is selected according to current device configuration in runtime
  • 54. Resources • resource units" – dp - density-independent pixel" – sp - scale-independent pixel (for fonts)" – never use px!!!
  • 55. Resource qualifiers • suffixes for resource folders" – drawables, drawable-mdpi, ..." – values, values-cs" – layout, layout-sw640dp" – drawable-hdpi-v11
  • 56. Resource qualifiers • screen density - ldpi, mdpi, hdpi, xhdpi, ..." • screen size - small, normal, large, xlarge" • screen orientation - port, land" • language - en, cs, sk, en-rGB…" • version - v11, v14, ...
  • 57. 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)
  • 58. 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)
  • 60. Android version fragmentation • How to handle different API levels available on different devices?
  • 61. Android version fragmentation • build target" – API level the app is compiled against" • AndroidManifest.xml" – <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
  • 62. Android version fragmentation • handling versions in code" if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {! ! // code for Android < 2.3! }
  • 63. 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;! }!
  • 64. 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
  • 65. Logging • java.util.logging.Logger • android.util.Log
  • 66. Toast • simple non-modal information" • displayed for a short period of time" • doesn’t have user focus
  • 67. 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();
  • 68. Sources • developer.android.com" • android-developers.blogspot.com" • source.android.com" • stackoverflow.com" • youtube.com/androiddevelopers" • svetandroida.cz