Back to Architecture Deep Dive

Android Components Deep Dive

Android Internals Team
2026-02-08
5 min read

Android Components Deep Dive

Android Components are the fundamental building blocks that enable inter-process communication and modular app architecture. These components work together through the Binder IPC mechanism to create Android's flexible application model.

1. Intents

Intents are messaging objects used to request an action from another app component. They're Android's primary mechanism for asynchronous communication between components.

💡 Analogy: Think of Intents as Envelopes with Instructions. You write a message ("Play this video"), address it (explicit) or describe who should handle it (implicit), and Android's postal service (ActivityManager) delivers it to the right component.

Intent Types:

TypeDescriptionExample
ExplicitSpecifies exact componentIntent(this, DetailActivity::class.java)
ImplicitDescribes action, system finds handlerIntent(Intent.ACTION_VIEW, uri)

2. Broadcast Receiver

Broadcast Receivers listen for system-wide or app-specific events and respond to them. They enable publish-subscribe patterns in Android.

💡 Analogy: Think of Broadcast Receivers as Radio Listeners. The system broadcasts events like "battery low" or "network connected" on specific channels, and your receivers tune in to the channels they care about.

Types of Broadcasts:

  1. System Broadcasts: Sent by Android system

    • ACTION_BOOT_COMPLETED - Device finished booting
    • ACTION_BATTERY_LOW - Battery is low
    • ACTION_POWER_CONNECTED - Charger plugged in
    • CONNECTIVITY_CHANGE - Network state changed
  2. Custom Broadcasts: Sent by your app

    • com.example.app.DATA_UPDATED
    • com.example.app.SYNC_COMPLETE

Background Execution Limits (Android 8+):

Manifest-registered receivers for implicit broadcasts are restricted. Use JobScheduler or WorkManager instead for background work.

📁 Official Documentation: Broadcasts

3. Content Provider

Content Providers manage access to a structured set of data, enabling secure data sharing between apps. They abstract the underlying storage mechanism (SQLite, files, network).

💡 Analogy: Think of Content Providers as Database APIs. Just like a REST API exposes database operations over HTTP, Content Providers expose CRUD operations over Binder IPC.

Common System Content Providers:

  • ContactsContract - Contacts database
  • MediaStore - Photos, videos, audio files
  • CalendarContract - Calendar events
  • Settings - System settings

📁 Official Documentation: Content Providers

4. Service Component

Services are components that run in the background to perform long-running operations without a user interface.

💡 Analogy: Think of Services as Background Workers. While Activities are the visible storefront, Services are the warehouse workers processing orders in the back.

Service Types:

TypeLifecycleUse Case
Started ServiceRuns until stoppedMusic playback, file download
Bound ServiceRuns while clients are boundLocation updates, data sync
Foreground ServiceRuns with notificationMusic player, navigation

Background Execution Limits:

Android 8+ restricts background services. Use:

  • WorkManager for deferrable background work
  • JobScheduler for scheduled tasks
  • Foreground Services for user-aware operations

📁 Official Documentation: Services

5. AIDL (Android Interface Definition Language)

AIDL is a tool for defining programming interfaces for inter-process communication (IPC) between apps using Binder. It's similar to protocol buffers or gRPC but specific to Android.

💡 Analogy: Think of AIDL as Contract Documents. When two apps need to communicate, AIDL defines the exact format of messages they can exchange, like a legal contract specifying terms.

When to Use AIDL:

  • Cross-process service communication
  • Sharing complex data structures between apps
  • Building client-server architectures
  • Note: For same-process communication, use regular interfaces

AIDL vs Regular Binder:

FeatureAIDLRegular Binder
Use caseCross-app IPCSame-app IPC
Code generationAutomaticManual
Type safetyStrongWeak
ComplexityHigherLower
PerformanceSame (both use Binder)Same

📁 Official Documentation: AIDL

Technical Deep Dive: Under the Hood

1. What is a "Context"?

Context is the most common object in Android development, but often the least understood. It is the Interface to the Global Information about an application environment.

  • Implementation: It is an abstract class. The actual implementation is ContextImpl.
  • Role: It provides access to:
    • Resources: getResources() (Strings, Drawables)
    • System Services: getSystemService() (Location, Notification)
    • File System: getFilesDir(), getDatabasePath()
  • Types:
    • Application Context: Singleton, lives as long as the app.
    • Activity Context: Lives only as long as the Activity. CAUTION: storing this in a static variable causes Memory Leaks.

2. ActivityThread: The "Main" Method

Java programs start with public static void main(). Where is it in Android? It is hidden inside ActivityThread.java.

  1. Zygote forks the process.
  2. ActivityThread.main() is called.
  3. It creates a Looper (Message Queue) for the main thread.
  4. It enters the infinite loop Looper.loop(), waiting for messages (like "Touch Event", "Draw Frame", "Start Activity") from the System Server.

Intent Resolution

When you send an implicit Intent (without specifying the exact component), Android must find which app can handle it. This is called Intent Resolution.

How Intent Matching Works

PackageManagerService performs a three-step matching algorithm:

1. Action Match

The Intent's action must match at least one action in the filter.

2. Category Match

All Intent categories must be present in the filter (filter can have extras).

3. Data Match (MIME type + URI scheme)

Both MIME type and URI scheme must match (if specified).

Query Installed Handlers

Resolution Priority

If multiple apps match:

  1. Preferred App: User has set a default (Settings → Default Apps)
  2. Priority: Higher android:priority in intent-filter wins
  3. App Chooser: System shows disambiguation dialog

Deep Links (implicit):

  • Any app can declare intent filters for URLs
  • User sees chooser if multiple apps match

App Links (verified):

  • Requires android:autoVerify="true" + Digital Asset Links file
  • System automatically opens your app (no chooser)

📁 Official Documentation: Intent Filters