01 - Android Intro
Topics
- Android overview
- Basic Android Studio usage
- Kotlin language
- UI creation
- App lifecycle and state
- Local storage and data access (SQLite)
- Sensors (proximity, geomagnetic, motion, GPS, …)
- Web services (REST API)
- Modern architecture
Android
Operating system, devised for mobile equipment (mostly)
Usage: phones, tablets, TV-s, watches, glasses, cars, laptops, cameras, game consoles, …
Market share among smartphones – ca 85% (iOS 14%)
Open-source project
Google apps and services are closed source (mail, map, etc.)
History
- 2003 – founded (lead: Andy Rubin)
- Initial idea – OS for cameras
- New plan – Mobile OS, (others: Symbian/Nokia and Win Mobile)
- 2005 – Google acquires the whole project
- 2007 – Open Handset Alliance
- Google, HTC, Sony, Samsung, Dell, Motorola, LG, Qualcomm, Intel, etc…
- 2008 – Android 1.0 (HTC Dream, no touchscreen)
- 2009 – Android 1.5 Cupcake (iPhone 2007, iPhone 3G 2008)
- 2010 – Android 2.2 Froyo, 2.3 Gingerbread
- 2011 – Android 3.0 Honeycomb (tablets only)
- 2011 - Android 4.0 Ice Cream Sandwich
- HOLO UI
- 2014 - Android 5 Lollipop
- Material design
- Dalvik vs ART (Android Runtime) (JIT or precompile, garbage collection)
- 2015 - Android 6 Marshmallow
- 2016 – Android 7 Nougat
- 2017 – Android 8 Oreo
- 2018 – Android 9 Pie
- 2019 – Android 10 Q – moves closer to iOS, security clamped down
Version distribution
2020
- Pie – 9.X – 10%
- Oreo – 8.X – 28%
- Nougat – 7.X - 19%
- Marshmallow – 6.X – 17%
- Lollipop - 5.X – 14%
- KitKat – 4.4 – 7%
- 4.4 and higher - ca 95%
Latest info (2022)
- 17 Jelly Bean 99.8%
- 19 KitKat 99.4%
- 22 LolliPop 97.3%
- 23 Nougat 85.6%
- 27 Oreo 78.7%
- 28 Pie 69%
- 29 Android 10 50.8%
- 30 Android 11 24.3%
Android Architecture
App types
- NDK - C/C++
- Close to hardware and operating system
- SDK - Native <- this course!!!!
- Kotlin/Java (ART/Dalvik), using system libraries
- Hybrid – React Native, Ionic, etc.
- Cross platform – Xamarin (C#), Flutter (Dart) etc.
- Html/JS – Progressive Web Apps
- One codebase/layout for different platforms
- Problems with UI, weak access to hardware
- There is also course on Hybrid Mobile Apps - ICD0018 (fall semester)
App architecture - AndroidManifest.xml
- The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code.
- Describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of.
- Declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
- Declares hardware requirements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
App architecture - build.gradle (app)
- Declares the minimum level of the Android API that the application requires (minSdk).
- Additional libraries (dependencies)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
App code
- MainActivity.kt
1 2 3 4 5 6 7 8 9 10 11 |
|
- actvity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
- UI generated from XML
Other resources
- Images
- Animations
- Menu
- Strings
- Misc files
APK
- Android Application Package
- ZIP file, combines all the resources and java bytecode
- Signed with developer key
- Developer key must be the same from version to next version
- Don’t lose your keys (passwords)
- Android Studio takes care of APK creation
- APK-s can be downloaded from store, using 3-rd party utilities
- Resources can be used as is
- Most elements/code can be decompiled/recompiled
Google Play - app store
- Almost no review process
- Problems are dealt with afterwards
- App hijacking, etc. are real problems
App security
- Every app works in its own private virtual machine (Zygote)
- Need permission for system resources/hardware
- confirmed on app install
- reconfirmed when app has not been used for some time
- Data is private, no other app can access directly other app data
- Everything is possible on rooted device
- End user is the weakest link
Developer problems
- Gazillion different hardware devices and capabilities
- Lots of different Android implementations
- Samsung TouchWiz
- HTC Sense
- ...
- Migration to newer versions very slow (or not done at all)
- Rooted phones
- Ca 2X time spent on development compared to iOS
- Ca 60% better income on iOS
Testing on devices
Device variability
Other hardware
Hands on demo time - Notes
findViewById vs
Add kotlin-android-extensions to build.gradle (deprecated) for initial view elemnts to code binding.
1 2 3 4 5 6 |
|
Remove virtual keyboard from screen when done with it
1 2 3 4 5 |
|