Android Programming Notes
Core Components
Activities
Represent a single screen with a user interface
Lifecycle methods:
o onCreate() - Initial setup
o onStart() - Becoming visible
o onResume() - Ready for interaction
o onPause() - Partially obscured
o onStop() - No longer visible
o onDestroy() - Before activity is destroyed
o onRestart() - Before restarting after stop
Services
Run in background for long-running operations
Types:
o Started (run until completion)
o Bound (client-server interface)
Broadcast Receivers
Respond to system-wide broadcast announcements
Can be registered in manifest or dynamically
Content Providers
Manage shared app data
Enable inter-app data sharing
UI Components
Views
Basic building blocks (buttons, text fields, etc.)
ViewGroup contains and arranges other views
Layouts
LinearLayout - arranges views horizontally/vertically
RelativeLayout - positions views relative to each other
ConstraintLayout - flexible positioning with constraints
FrameLayout - stacks views (single view typically)
RecyclerView - efficient scrolling lists
Fragments
Modular UI components with own lifecycle
Can be combined in activities
Key Concepts
Intents
Messaging objects for component communication
Explicit (target specific component)
Implicit (declare general action)
Manifest File
Declares app components, permissions, requirements
Located at app/manifests/AndroidManifest.xml
Gradle Build System
Manages dependencies and build configurations
build.gradle files (project and module level)
Storage Options
1. SharedPreferences - simple key-value pairs
2. Internal Storage - private app files
3. External Storage - public files
4. SQLite Databases - structured data
5. Room Persistence Library - SQLite abstraction layer
6. Network/Cloud Storage
Threading
Main Thread (UI Thread)
Only thread that can update UI
Long operations must not block it
Worker Threads
AsyncTask (deprecated in API 30)
Handler and Looper
ThreadPools
Kotlin Coroutines (recommended)
RxJava
Modern Android Development
Jetpack Components
ViewModel - manage UI-related data
LiveData - observable data holder
Room - database abstraction
WorkManager - deferrable background work
Navigation - in-app navigation
Architecture Components
Recommended app architecture patterns (MVVM)
Lifecycle-aware components
Kotlin
Modern, concise language for Android
Null safety, extension functions, coroutines
Debugging Tools
Logcat - system logs
Android Profiler - CPU, memory, network
Layout Inspector - view hierarchy
ADB (Android Debug Bridge) - command line tools
Testing
Unit tests (JUnit)
Instrumentation tests (Espresso, UI Automator)
Deployment
APK (Android Package)
AAB (Android App Bundle) - preferred format
Google Play Store submission requirements