Structure of Android OS 

Android operating system consist of several layers, which are staring from bottom to top

  1. Linux Kernel : Takes care of threading, memory management, process management, hardware drivers, networking and security. Includes drivers for camera, audio, keypad, bluetooth, etc.
  2. Hardware Abstraction Layer HAL - Exposes hardware capabilities of hardware components such as Bluetooth, Camera etc to the Kotlin API through standard interfaces. When device is needed, the Kotlin API makes a call to the interface and a corresponding library is loaded for the hardware component.
  3. Android Runtime ART - Environment used to run the applications. Each application runs in its own process. Designed based on Java Virtual Machine to run apps in shared environment, where battery, CPU, memory are limited. Reads .dex files.
  4. Native C/C++ Libraries - Used to build core Android components such as ART and HAL.Their functionalities are exposed by Java Framework API
  5. Java API Framework - Set of APIs written in Java exposing Android features.  Key services and components:
    • View System - to build the UI
    • Managers- Notification, Activity, Content , Resource (strings, graphics, layers) etc
    • Content Providers to share data with other apps
  6. System Apps - Email, Calendar, Camera, etc. Android comes preinstalled with them. Your apps can invoked them to reuse functionality. Can be replaced with custom apps.

Android Libraries

  • Designed to be used by multiple Android apps. 
  • Example:  multiple apps needing the same components, multiple APK variations of the same app - paid and free needing the same core components. 
  • Has the same structure as Android app module - manifest, resources, source code. 

Main libraries

android.view - TextView, ImageView, etc

android.widget - includes components such as Button, Spinner etc.

Components of Android Application

  1. Activities: each screen extends the activity class. Made up of several views grouped in a layout
  2. Services: invisible, runs in background, no UI, performs continuous processing
  3. Content Providers: to share data between part of the app or different apps. Data can be stored in database, files, etcAndroid uses content providers to expose contacts, call logs etc.
  4. Intents: used to send messages across the Whole Android system. Can start activity, start service, etc. The Android system interprets them and determines the target that will perform the action
  5. Broadcast Recievers: added to an app to receive messages from intents 
  6. Views: objects drawn on the screen. Parents of all UI components
  7. Widgets: part of an app, such as Button, AppBar, Bottom Navigation, have rounded corners starting from Android 12
  8. Notifications:  Appear on the status bar, popup style messages

App Life cycle 

onCreate -> onStart -> onResume -> onPause -> onStop -> onDestroy

Types of Android Processes

Android assigns priority to processes and can kill process to free resources based on its priority. Types of processes starting with highest priority

  • Foreground Process - visible and active, very few, killed as last resort
  • Visible Process - visible and inactive, not responding to user events, maybe partially obscured, very few, killed in extreme circumstances
  • Service Process - no visible interface , continuous processing, still considered foreground, not killed unless resources are needed
  • Background Process - not visible, have pending services, killed in last seen, first killed basis
  • Empty - app retained in memory to improve startup time, no active components, routinely killed

Android SDK

Consists of
  • Android SDK Tools - development and debugging tools
  • SDK Build tools - required to build the app code, continuously runs in the background

Android Studio

  • Google's official IDE for Android app development
  • Based on InetlliJ IDEA
  • Uses Android SDK
  • Prerequisites to install: Java JDK and JAVA JRE

Considerations when creating new project n Android Studio

- Target new Android OS to bre able to use new features, but not the latest so your app can be used by majority of Android devices.

What you need to run apps

  • Intel x86 Emulator Accelerator
  • Phone Emulator = Android Virtual Device (AVD)
  • Cable that transfers both power and data to physical device
  • Instant Run
    • Apply Changes and Restart activity
    • Apply Changes
  • AVD Manager
    • you need BIOS to enable virtualization

Android Studio Gradle

Build Automation Tool
Build scripts written in Groovy or Kotlin DSL
Build, run, test, package applications






Comments