Skip to content

The Android framework APIs: core packages and app components

What people sometimes call the “Android standard library” is officially the Android framework API: the android.* packages your app compiles against (android.jar in the SDK) and that each device provides at runtime. Its public surface is Java, callable from Java or Kotlin; much of the implementation underneath is native C/C++. Because the version on a device depends on its OS release, Google ships most newer APIs separately as AndroidX (Jetpack) libraries that you bundle with your app.

This post maps the main packages and then covers the four app components the framework is built around.

PackageWhat’s in itExample classes
android.appApp-level components and system servicesActivity, Service, Application, NotificationManager, AlarmManager
android.contentInter-component plumbing and data accessContext, Intent, ContentProvider, ContentResolver, BroadcastReceiver, SharedPreferences
android.content.pmInformation about installed packagesPackageManager, PackageInfo
android.osThreads, messaging, system infoLooper, Handler, Bundle, Build, PowerManager, Vibrator
android.graphics2D drawingCanvas, Paint, Bitmap, Path
android.hardwareSensors and other hardwareSensorManager, Sensor; cameras via android.hardware.camera2
android.locationLocationLocationManager, Location
android.viewThe base UI system and inputView, ViewGroup, LayoutInflater, MotionEvent
android.widgetBuilt-in View-based UI componentsTextView, Button, EditText, ImageView, LinearLayout

A few things that are commonly assumed to be in the framework but aren’t, or are no longer recommended:

  • DrawerLayout, RecyclerView, ViewPager2 and AppCompatActivity are AndroidX libraries, not android.widget or android.app.
  • android.hardware.Camera was deprecated in API 21 in favour of camera2; most apps now use the Jetpack CameraX library.
  • ListView and GridView still exist, but new View-based code uses RecyclerView, and new UI is increasingly written in Jetpack Compose, which doesn’t use android.widget at all.

Android starts your app through components declared in AndroidManifest.xml. There are four kinds.

An Activity is a single screen. The system drives its lifecycle (onCreate, onStart, onResume, onPause, onStop, onDestroy) as the user navigates and as the app moves between foreground and background. In practice you extend AppCompatActivity or ComponentActivity from AndroidX rather than the framework Activity directly, so newer features work on older OS versions.

An Intent is a message asking the system to start a component. An explicit intent names the target class; an implicit intent describes an action (such as Intent.ACTION_VIEW with a URL) and lets the system find an app that can handle it. Extra data travels with the intent as key/value pairs in a Bundle.

Here is an activity that opens another one with an explicit intent and passes an ID:

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<Button>(R.id.open_details).setOnClickListener {
val intent = Intent(this, DetailActivity::class.java)
.putExtra(DetailActivity.EXTRA_ITEM_ID, 42L)
startActivity(intent)
}
}
}
class DetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_detail)
val itemId = intent.getLongExtra(EXTRA_ITEM_ID, -1L)
findViewById<TextView>(R.id.item_label).text = "Item $itemId"
}
companion object {
const val EXTRA_ITEM_ID = "item_id"
}
}

Both activities must be declared in the manifest with <activity> elements, or startActivity throws ActivityNotFoundException.

A Service runs work without a UI. Since Android 8.0 (API 26), apps in the background can’t freely start services, and long-running work has to be a foreground service that shows a notification; Android 14 additionally requires each foreground service to declare a type (such as mediaPlayback or dataSync). IntentService was deprecated in API 30. For deferrable background work (syncing, uploads), use Jetpack WorkManager instead of a service.

A ContentProvider exposes structured data to other apps (or other processes) through content:// URIs. You implement query, insert, update, delete and getType; clients call the same methods through a ContentResolver. The system’s contacts, calendar and media store are all providers. If the data is only used inside your own app, you don’t need one; a Room database or DataStore is simpler.

A BroadcastReceiver responds to system or app events in onReceive. Since Android 8.0, most implicit system broadcasts can no longer be received by receivers declared in the manifest; register those at runtime with Context.registerReceiver while your app is running. Keep onReceive short: it runs on the main thread and the system may kill the process soon after it returns.

© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)