Skip to content

Android Components and Lifecycle Interview Questions for Android App Development

25 Android Components and Lifecycle questions with answers for android app development roles — 8 easy, 13 medium, 4 hard.

About Android Components and Lifecycle

Activities, fragments, services, broadcast receivers and content providers are the building blocks of every Android app. This topic covers lifecycles, configuration changes, process death, intents, deep links, permissions, notifications and background limits. Strong answers here show you understand how the Android system actually runs and kills your app.

Sheet progressStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

What are the four main Android app components?

Save to ▾
Show answer
Activities provide a screen the user interacts with. Services run work without a UI, such as music playback. Broadcast receivers respond to system or app-wide events like boot completed or connectivity change. Content providers share structured data between apps, such as contacts. Each component is an entry point the system can start, and most must be declared in AndroidManifest.xml with appropriate intent filters and permissions.
02

Explain the Activity lifecycle.

Save to ▾
Show answer
onCreate runs once to set up the UI and state. onStart makes the activity visible, onResume makes it interactive in the foreground. onPause runs when it loses focus, onStop when it is no longer visible, and onDestroy before it is removed. Rotation by default destroys and recreates the activity. Release resources like camera in onPause or onStop, and save transient UI state with ViewModel and SavedStateHandle.
03

What happens on a configuration change such as screen rotation?

Save to ▾
Show answer
By default the system destroys and recreates the Activity so it can load resources for the new configuration, like landscape layouts or a new language. Fields in the Activity are lost, but a ViewModel survives because it is kept by the ViewModelStore. Views with IDs restore some state automatically, and rememberSaveable in Compose restores small state. Handling changes manually via configChanges is possible but should be a deliberate choice.
04

What is the difference between explicit and implicit intents?

Save to ▾
Show answer
An explicit intent names the exact component to start, like Intent(this, DetailActivity::class.java), and is used inside your own app. An implicit intent declares an action and data, such as ACTION_VIEW with a URL or ACTION_SEND with text, and the system finds apps that can handle it through intent filters. For implicit intents, handle the case where no app can respond, and since Android 11 declare package visibility queries when needed.
05

How do runtime permissions work in modern Android?

Save to ▾
Show answer
Dangerous permissions like camera, location and notifications (POST_NOTIFICATIONS since Android 13) must be declared in the manifest and requested at runtime. Use the Activity Result API with RequestPermission or RequestMultiplePermissions contracts. Show a rationale when shouldShowRequestPermissionRationale returns true, handle denial gracefully, and direct users to settings if they deny permanently. Request permissions in context, at the moment the feature needs them.
06

What is the role of AndroidManifest.xml?

Save to ▾
Show answer
The manifest declares the app's package identity, components (activities, services, receivers, providers), intent filters, permissions, hardware features, and app-level settings like theme, backup rules and exported flags. Since Android 12, components with intent filters must set android:exported explicitly. Gradle merges manifests from libraries into the final one, so check the merged manifest when unexpected permissions appear in your release build.
07

What is the difference between Parcelable and Serializable?

Save to ▾
Show answer
Serializable is a Java marker interface that uses reflection and creates many temporary objects, so it is slower. Parcelable is Android-specific and writes fields explicitly to a Parcel, which is much faster for IPC. Writing Parcelable by hand is verbose, but the kotlin-parcelize plugin with @Parcelize generates it. Use Parcelable for Bundles and intents, and never use either as a long-term storage format.
08

How do you explain a technical limitation to a non-technical product manager?

Save to ▾
Show answer
I focus on user impact and options rather than jargon. For example, when asked for background tracking every second, I explained that Android limits background work to save battery, so the app would need a visible notification and stricter Play review. I offered two options with trade-offs and a recommendation. Using a simple diagram helped, and the PM chose the option that met the business need with fewer risks.
09

Explain the Fragment lifecycle and why viewLifecycleOwner matters.

Save to ▾
Show answer
A Fragment has its own lifecycle (onCreate to onDestroy) and a separate view lifecycle (onCreateView to onDestroyView). When a fragment goes to the back stack its view is destroyed but the fragment instance may stay. If you observe LiveData or collect flows with the fragment itself as owner, observers pile up and can touch a dead view. Use viewLifecycleOwner and clear view binding references in onDestroyView.
10

What are launch modes and task affinity?

Save to ▾
Show answer
Launch modes control how an Activity instance joins a task. standard creates a new instance each time. singleTop reuses the instance at the top and calls onNewIntent. singleTask keeps one instance in its task and clears activities above it. singleInstance puts it alone in a task, and singleInstancePerTask exists since Android 12. Intent flags like FLAG_ACTIVITY_CLEAR_TOP give similar control. Most modern single-activity apps rarely need them.
11

What is the difference between a started service, bound service and foreground service?

Save to ▾
Show answer
A started service runs after startService until it stops itself. A bound service offers a client-server interface to components that bind to it and stops when all unbind. A foreground service shows a persistent notification and has higher priority, used for music, navigation or ongoing calls. Since Android 14 a foreground service must declare a type such as mediaPlayback or location. For deferrable background work, use WorkManager instead.
12

Write code to request camera permission using the Activity Result API.

Save to ▾
Show answer
private val cameraPermission = registerForActivityResult( ActivityResultContracts.RequestPermission() ) { granted -> if (granted) openCamera() else showPermissionDenied() } fun onScanClicked() { when { ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED -> openCamera() shouldShowRequestPermissionRationale(Manifest.permission.CAMERA) -> showRationale { cameraPermission.launch(Manifest.permission.CAMERA) } else -> cameraPermission.launch(Manifest.permission.CAMERA) } }
13

What is a BroadcastReceiver and what limits apply since Android 8?

Save to ▾
Show answer
A BroadcastReceiver responds to broadcast intents. Since Android 8, most implicit broadcasts cannot be received by receivers declared in the manifest; you register them at runtime with registerReceiver while the app is running. A few exemptions exist, like BOOT_COMPLETED and locale change. Since Android 14, runtime receivers must specify RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED. onReceive runs on the main thread, so keep it short or use goAsync.
14

What is a ContentProvider and when would you build one?

Save to ▾
Show answer
A ContentProvider exposes data through a URI-based interface with query, insert, update and delete, and handles permissions for cross-app access. You need one when sharing data with other apps, providing search suggestions, or supporting widgets that read your data. FileProvider is a ready-made provider for sharing files securely with content URIs instead of file paths. For data used only inside your app, Room is simpler.
15

How do you pass data between screens and what is the size limit?

Save to ▾
Show answer
Traditionally through Intent extras or Fragment arguments as a Bundle with primitives, Parcelable or Serializable objects. Bundles go through Binder transactions, which have a shared limit of about 1 MB, so large data causes TransactionTooLargeException. Pass an ID instead and load the data from a repository or database on the next screen. With Navigation, use type-safe route arguments and a shared ViewModel only when screens truly share state.
16

Write a manifest entry for a deep link that opens a product screen.

Save to ▾
Show answer
<activity android:name=".MainActivity" android:exported="true"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="shop.example.com" android:pathPrefix="/product" /> </intent-filter> </activity> <!-- autoVerify plus assetlinks.json on the domain makes it an App Link -->
17

What is the difference between a deep link and an Android App Link?

Save to ▾
Show answer
A deep link is any intent filter that opens your app for a URI; if several apps can handle it, the user sees a chooser. An App Link is an HTTPS deep link verified with android:autoVerify and a Digital Asset Links file at /.well-known/assetlinks.json on your domain, containing your app's signing certificate fingerprint. Verified links open your app directly. Remember to include the Play App Signing key fingerprint.
18

Users report the app loses form data when they switch to another app and come back after a while. Why?

Save to ▾
Show answer
The system killed the process to reclaim memory while the app was in the background. When the user returns, Android recreates the Activity but ViewModel data is gone because the process died. Fix it by storing small UI state in SavedStateHandle or rememberSaveable, which survive process death, and persisting drafts to Room or DataStore. Test with Don't keep activities or adb shell am kill.
19

Write code to show a notification with a channel.

Save to ▾
Show answer
fun showOrderNotification(context: Context, text: String) { val channelId = "orders" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel( channelId, "Order updates", NotificationManager.IMPORTANCE_DEFAULT) context.getSystemService(NotificationManager::class.java) .createNotificationChannel(channel) } val n = NotificationCompat.Builder(context, channelId) .setSmallIcon(R.drawable.ic_order) .setContentTitle("Order update") .setContentText(text) .setAutoCancel(true) .build() NotificationManagerCompat.from(context).notify(1001, n) }
20

How do you build a single-activity app with the Navigation component?

Save to ▾
Show answer
Keep one Activity hosting a NavHost, and represent each screen as a Compose destination or Fragment. Define routes in a navigation graph, preferably with type-safe routes using Kotlin serialization in Navigation 2.8 and later. Use nested graphs for flows like login or checkout, pop the back stack with popUpTo when finishing a flow, and handle deep links on destinations. This simplifies shared transitions and state handling.
21

Tell me about a time you handled a production crash under pressure.

Save to ▾
Show answer
Situation: after a release, crash-free users dropped from 99.6 to 97 percent. Task: stop the impact fast. Action: I checked Crashlytics, found a crash on Android 14 caused by a missing foreground service type, paused the staged rollout in Play Console, shipped a hotfix with a test on an emulator for that API level, and wrote a short postmortem. Result: crash rate recovered within a day and we added API-level checks to our release checklist.
22

A crash says IllegalStateException: Can not perform this action after onSaveInstanceState. What is happening?

Save to ▾
Show answer
A fragment transaction or dialog show was committed after the Activity saved its state, usually because a network callback finished while the app was in background. Committing then would lose state. Fix by triggering navigation only when the lifecycle is at least STARTED, collecting events with repeatOnLifecycle, or deferring the action. commitAllowingStateLoss hides the crash but can lose the transaction, so use it only when that is acceptable.
23

The product team wants location tracking for delivery partners even when the app is closed. How do you implement it?

Save to ▾
Show answer
Use a foreground service with foregroundServiceType location, a visible notification, and the FusedLocationProviderClient with a sensible interval. Request ACCESS_FINE_LOCATION first, then ACCESS_BACKGROUND_LOCATION separately where truly needed, explaining why. Declare foreground service permissions for Android 14. Batch and upload locations efficiently, handle battery optimisation, and complete the Play Console location permissions declaration, since background location is reviewed strictly.
24

How does Android handle background execution limits and Doze mode?

Save to ▾
Show answer
Doze defers network access, jobs, alarms and syncs when the device is idle, with short maintenance windows. App Standby Buckets limit how often apps run based on usage. Since Android 8, background services are restricted, and since Android 12 apps cannot start foreground services from background except in specific cases. Use WorkManager for deferrable work, FCM high-priority messages for urgent pushes, and exact alarms only when truly required.
25

What is the predictive back gesture and how do you support it?

Save to ▾
Show answer
Predictive back, introduced in Android 13 and on by default for apps targeting Android 15, shows a preview of the destination while the user swipes back. Support it by setting android:enableOnBackInvokedCallback="true" and handling back with OnBackPressedDispatcher or BackHandler in Compose instead of overriding onBackPressed, which is deprecated. Navigation libraries and Material components provide animations when you use the supported APIs.

Frequently asked questions

How important is Android Components and Lifecycle in Android App Development interviews?

Activities, fragments, services, broadcast receivers and content providers are the building blocks of every Android app. This topic covers lifecycles, configuration changes, process death, intents, deep links, permissions, notifications and background limits. Strong answers here show you understand how the Android system actually runs and kills your app.

How should I use the Android Components and Lifecycle sheet?

Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.