Sparround

The four app components & intents

An Android app is built from 4 component types — each an entry point into the app for the system:

  • Activity — one UI screen; the entry point for user interaction.
  • Service — UI-less background work (music, sync). A foreground service is visible to the user via a notification.
  • BroadcastReceiver — reacts to system/app events (connectivity changed, boot completed).
  • ContentProvider — structured data sharing across apps (e.g. contacts).

Components are activated by Intents (except ContentProvider, which uses ContentResolver). An explicit intent names the exact class (navigating your own screens); an implicit intent declares an action (ACTION_VIEW, ACTION_SEND) and the system finds a matching component.

kotlin
// Explicit — konkret ekran
val intent = Intent(this, TransferActivity::class.java).apply {
    putExtra("accountId", accountId)
}
startActivity(intent)

// Implicit — sistem uyğun tətbiqi tapır
val share = Intent(Intent.ACTION_SEND).apply {
    type = "text/plain"
    putExtra(Intent.EXTRA_TEXT, "Qəbz #12345")
}
startActivity(Intent.createChooser(share, null))

Explicit vs implicit intent

Banking context: sending sensitive data via implicit intents is risky — nothing guarantees which app responds. For internal navigation always use explicit intents, exported="false" components, and minimal data in extras. Since Android 12 the exported attribute is mandatory for components with intent filters.

🛠 Practice task

Manifest drill: open an existing (or a fresh empty) project and check the exported value of every component in the manifest.

  • Write one explicit and one implicit intent (sharing a receipt via ACTION_SEND).
  • Look at which apps the implicit intent offers — why must sensitive data never travel this way?
  • Write a table: 5 use cases → which component.

Done when: you can answer "which component would you use" without looking it up.

📚 Sources and documentation