Top Android Interview Questions & Answers
This comprehensive guide covers the most frequently asked Android interview questions — from fundamental concepts to advanced topics like the Activity lifecycle, RecyclerView, networking, permissions, and publishing. Whether you're a fresher or an experienced developer, these questions will help you succeed in your Android developer interview.
Section 1: Android Basics
Q1. What is Android?
Answer: Android is a mobile operating system based on a modified version of the Linux kernel. It's designed primarily for touchscreen mobile devices such as smartphones and tablets. It's developed by Google and the Open Handset Alliance.
Q2. What are the four main components of an Android app?
Answer: The four main components are:
- Activity: A UI screen that the user interacts with.
- Service: A background component for long-running operations.
- Broadcast Receiver: Responds to system-wide broadcast announcements.
- Content Provider: Manages access to a structured set of data.
Q3. What is the difference between dp, sp, and px?
Answer:
- dp (Density-independent pixels): Scales based on screen density. Use for layout dimensions.
- sp (Scale-independent pixels): Scales based on screen density AND user font size preferences. Use for text sizes.
- px (Pixels): Absolute pixel values. Avoid using — they don't scale across devices.
Q4. What is the difference between match_parent and wrap_content?
Answer: match_parent makes the view as large as its parent container. wrap_content makes the view only as large as its content requires.
Q5. What is the AndroidManifest.xml file?
Answer: The AndroidManifest.xml is a required file that describes essential information about your app to the Android system. It declares all components (activities, services, etc.), permissions, features, and the app's package name.
Q6. What is the difference between java and kotlin for Android development?
Answer: Kotlin is a modern, statically-typed language that is fully interoperable with Java. It offers null safety, extension functions, data classes, coroutines for async programming, and less boilerplate code. Google officially recommends Kotlin for Android development.
Section 2: Activity & Lifecycle
Q7. What is the Activity lifecycle?
Answer: The Activity lifecycle is a series of callback methods that the Android system calls as the activity transitions between different states:
onCreate()— Activity is first created.onStart()— Activity becomes visible.onResume()— Activity is in the foreground and interactive.onPause()— Activity is partially obscured.onStop()— Activity is no longer visible.onRestart()— Activity is restarting after being stopped.onDestroy()— Activity is being destroyed.
Q8. What happens when you rotate the screen?
Answer: By default, the activity is destroyed and recreated when the screen is rotated. The lifecycle methods called are: onPause() → onStop() → onDestroy() → onCreate() → onStart() → onResume().
Q9. How do you save and restore state on configuration changes?
Answer: Use onSaveInstanceState() to save data before destruction, and restore it in onCreate() or onRestoreInstanceState(). Alternatively, use ViewModel which survives configuration changes.
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString("key", "value")
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val value = savedInstanceState?.getString("key")
}
Q10. What is the difference between onPause() and onStop()?
Answer: onPause() is called when the activity is partially obscured (e.g., a dialog appears) or when the user is leaving the activity. onStop() is called when the activity is no longer visible to the user (e.g., another activity covers it completely).
Q11. What is a Service and how is it different from an Activity?
Answer: A Service is a component that runs in the background without a user interface. An Activity has a UI and is visible to the user. Services are used for long-running operations like playing music, downloading files, or syncing data.
Q12. What is the difference between a started service and a bound service?
Answer: A started service is launched by startService() and runs until it stops itself or is stopped. A bound service is launched by bindService() and allows client-server interaction. Bound services stop when all clients unbind.
Section 3: UI & Layouts
Q13. What is the difference between LinearLayout and ConstraintLayout?
Answer: LinearLayout arranges children in a single row or column. ConstraintLayout is more flexible and powerful, allowing you to create complex layouts with a flat view hierarchy. ConstraintLayout is more efficient and recommended for all new projects.
Q14. What is layout_weight in LinearLayout?
Answer: layout_weight is used to distribute remaining space among children. A child with a weight of 1 will take up more space than a child with weight 0. The total weight sum determines the proportion of space each child receives.
<LinearLayout android:weightSum="2" ...>
<View android:layout_width="0dp" android:layout_weight="1" />
<View android:layout_width="0dp" android:layout_weight="1" />
</LinearLayout>
Q15. What is RecyclerView and how is it better than ListView?
Answer: RecyclerView is a more advanced version of ListView. It:
- Reuses views efficiently (ViewHolder pattern)
- Supports multiple layouts per list
- Has built-in animations
- Separates layout management (LayoutManager)
- Provides better performance for large lists
Q16. What is the ViewHolder pattern?
Answer: The ViewHolder pattern is a design pattern used in RecyclerView to improve performance. A ViewHolder object holds references to the views in a list item, avoiding expensive findViewById() calls during scrolling.
Q17. What is the difference between android:gravity and android:layout_gravity?
Answer: android:gravity aligns the content inside the view. android:layout_gravity aligns the view itself within its parent container.
Section 4: Intents & Navigation
Q18. What is an Intent?
Answer: An Intent is a messaging object used to request an action from another app component. It can be used to start activities, start services, or send broadcasts. There are two types: explicit and implicit intents.
Q19. What is the difference between an explicit and implicit intent?
Answer: An explicit intent specifies the exact component (Activity, Service) to start by name. An implicit intent declares a general action to be performed, and the Android system finds the best component to handle it (e.g., opening a URL).
Q20. How do you pass data between activities?
Answer: Use Intent.putExtra() to pass data, and getStringExtra(), getIntExtra(), etc., to receive it. For custom objects, implement Parcelable or Serializable.
// Send
val intent = Intent(this, SecondActivity::class.java)
intent.putExtra("key", "value")
startActivity(intent)
// Receive
val value = intent.getStringExtra("key")
Q21. What is the difference between startActivity() and startActivityForResult()?
Answer: startActivity() starts a new activity without expecting a result. startActivityForResult() starts an activity and expects a result to be returned via onActivityResult() (deprecated, use Activity Result API instead).
Q22. What is an Intent Filter?
Answer: An Intent Filter is declared in the AndroidManifest.xml file to specify what types of implicit intents an activity can handle. It defines the action, category, and data that the component supports.
Section 5: Data Storage
Q23. What is SharedPreferences and when would you use it?
Answer: SharedPreferences is a key-value storage system for storing simple data like user preferences, settings, or login state. It's suitable for small amounts of data (less than 1-2 MB).
Q24. What is the difference between apply() and commit() in SharedPreferences?
Answer: apply() writes asynchronously on a background thread and returns immediately. commit() writes synchronously on the main thread and returns a boolean result. Use apply() unless you need the result immediately.
Q25. What is SQLite and what is Room?
Answer: SQLite is a lightweight relational database embedded in Android. Room is a persistence library that provides an abstraction layer over SQLite, offering compile-time validation, less boilerplate, and better integration with LiveData and coroutines.
Q26. What are the three main components of Room?
Answer:
- Entity: Represents a table (data class with @Entity).
- DAO (Data Access Object): Defines database operations (@Insert, @Update, @Delete, @Query).
- Database: The main access point (@Database class).
Q27. What is the difference between internal and external storage?
Answer: Internal storage is private to the app, automatically deleted when the app is uninstalled, and not accessible by other apps. External storage (like SD card) is shared, can be accessed by other apps, and may be visible to the user.
Section 6: Networking
Q28. What is Retrofit and why is it used?
Answer: Retrofit is a type-safe HTTP client for Android. It makes API calls easier by converting HTTP API responses into Java/Kotlin objects. It's the industry-standard networking library for Android.
Q29. How do you handle network calls in Android without blocking the UI thread?
Answer: Use coroutines with Dispatchers.IO or viewModelScope. Never make network calls on the main thread — it causes ANR (Application Not Responding).
viewModelScope.launch(Dispatchers.IO) {
val response = apiService.getUsers()
withContext(Dispatchers.Main) {
// Update UI
}
}
Q30. What is an interceptor in Retrofit?
Answer: An interceptor is a component that intercepts HTTP requests and responses. They are used for adding headers (authentication), logging, retrying failed requests, and modifying requests/responses.
Q31. How do you handle network errors in Android?
Answer: Use try-catch blocks around network calls. Check for connectivity using ConnectivityManager. Handle HTTP status codes (200 OK, 404 Not Found, 500 Internal Server Error, etc.). Show user-friendly error messages.
Q32. What is JSON and how is it parsed in Android?
Answer: JSON (JavaScript Object Notation) is a lightweight data-interchange format. In Android, it's parsed using Gson (with Retrofit), Moshi, or the built-in JSONObject and JSONArray classes.
Section 7: Permissions
Q33. What is the difference between normal and dangerous permissions?
Answer: Normal permissions are low-risk and automatically granted (e.g., INTERNET). Dangerous permissions access sensitive data and must be requested at runtime (e.g., CAMERA, READ_CONTACTS).
Q34. How do you request runtime permissions in Android?
Answer: Use the Activity Result API (registerForActivityResult with ActivityResultContracts.RequestPermission or RequestMultiplePermissions) to request permissions and handle the result.
private val permissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted ->
if (isGranted) { /* Proceed */ }
else { /* Handle denial */ }
}
permissionLauncher.launch(Manifest.permission.CAMERA)
Q35. What is shouldShowRequestPermissionRationale()?
Answer: This method returns true if the user has previously denied the permission but has not checked "Never ask again". Use it to show an explanation of why the permission is needed before requesting again.
Q36. How do you handle permanently denied permissions?
Answer: Check shouldShowRequestPermissionRationale() — if it returns false and the permission is denied, the user has permanently denied it. Guide the user to app settings to enable the permission.
Section 8: Advanced Topics
Q37. What is the difference between android:exported and android:permission?
Answer: android:exported determines whether a component (activity, service, receiver) can be accessed by other apps. android:permission specifies the permission required to access that component.
Q38. What is the difference between a Fragment and an Activity?
Answer: A Fragment is a modular UI component that runs inside an Activity. Fragments have their own lifecycle, receive their own input events, and can be added/removed dynamically. An Activity is a standalone UI screen.
Q39. What is a ViewModel and why is it used?
Answer: ViewModel is a class that stores UI-related data in a lifecycle-conscious way. It survives configuration changes (like screen rotation) and is used to separate UI logic from activity/fragment lifecycle.
Q40. What is the difference between LiveData and Flow?
Answer: LiveData is a lifecycle-aware observable data holder. Flow is a Kotlin coroutine-based stream that provides more powerful operators and more control over threading. Flow is recommended for new projects.
Q41. What is the difference between a BroadcastReceiver and a Service?
Answer: A BroadcastReceiver is a short-lived component that responds to system events. A Service is a long-running component that performs background operations. BroadcastReceivers should not perform long-running operations — they can cause ANRs.
Q42. What is a ContentProvider?
Answer: A ContentProvider is a component that manages access to a structured set of data. It's the only way to securely share data between different applications (e.g., contacts, media files).
Q43. What is the difference between Parcelable and Serializable?
Answer: Parcelable is an Android-specific interface for fast serialization. It's more efficient than Java's Serializable because it writes data in a structured format. Use Parcelable for passing data between components in Android.
Section 9: Publishing & Production
Q44. What is the difference between an APK and an AAB?
Answer: APK (Android Package Kit) is the traditional distribution format. AAB (Android App Bundle) is the newer format that allows Google Play to optimize and split the app for different device configurations, resulting in smaller download sizes.
Q45. What is a keystore and why is it important?
Answer: A keystore is a digital certificate used to sign your app. It proves that you are the author of the app and is required for publishing updates. If you lose your keystore, you cannot update your app.
Q46. What is Proguard/R8 and why is it used?
Answer: Proguard (R8 is the newer version) is a tool that shrinks, optimizes, and obfuscates your code. It reduces the APK size and makes reverse engineering harder by renaming classes and methods to meaningless names.
Q47. What are the release tracks in Google Play Console?
Answer: Google Play Console has four release tracks:
- Internal Testing: Up to 100 testers (quick testing).
- Closed Testing: Up to 1000 testers (controlled testing).
- Open Testing: Unlimited testers (public beta).
- Production: Public release to all users.
Q48. What is Google Play App Signing?
Answer: Google Play App Signing is a service where Google manages your app's signing key. It allows you to upload an AAB file and Google signs it before distributing. It's recommended because it enables features like AAB optimization and secure key management.
Q49. What is the difference between versionCode and versionName?
Answer: versionCode is an integer used by the system to determine if an update is available (must increment for each release). versionName is a human-readable version string (e.g., "1.0.0") shown to users.
Section 10: Common Coding Challenges
Q50. Write a function to check if a permission is granted.
fun isPermissionGranted(context: Context, permission: String): Boolean {
return ContextCompat.checkSelfPermission(context, permission)
== PackageManager.PERMISSION_GRANTED
}
Q51. Write a Retrofit API interface for a GET request.
interface ApiService {
@GET("users")
suspend fun getUsers(): Response<List<User>>
@GET("users/{id}")
suspend fun getUserById(@Path("id") userId: Int): Response<User>
}
Q52. Write a Room Entity class.
@Entity(tableName = "users")
data class User(
@PrimaryKey(autoGenerate = true)
val id: Long = 0,
val name: String,
val email: String
)
Q53. Write a RecyclerView Adapter.
class UserAdapter(
private var users: List<User>,
private val onItemClick: (User) -> Unit
) : RecyclerView.Adapter<UserAdapter.UserViewHolder>() {
class UserViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val nameTextView: TextView = itemView.findViewById(R.id.nameTextView)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_user, parent, false)
return UserViewHolder(view)
}
override fun onBindViewHolder(holder: UserViewHolder, position: Int) {
val user = users[position]
holder.nameTextView.text = user.name
holder.itemView.setOnClickListener { onItemClick(user) }
}
override fun getItemCount(): Int = users.size
}
Q54. Write a function to save and retrieve data from SharedPreferences.
object PreferenceManager {
private const val PREF_NAME = "my_preferences"
fun saveString(context: Context, key: String, value: String) {
val prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
prefs.edit().putString(key, value).apply()
}
fun getString(context: Context, key: String, defaultValue: String = ""): String {
val prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
return prefs.getString(key, defaultValue) ?: defaultValue
}
}
Q55. Write a function to check internet connectivity.
fun isNetworkAvailable(context: Context): Boolean {
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkCapabilities = connectivityManager.activeNetwork ?: return false
val activeNetwork = connectivityManager.getNetworkCapabilities(networkCapabilities) ?: return false
return activeNetwork.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
}
Quick Reference — Key Concepts
| Concept | Description | When to Use |
|---|---|---|
| Activity | UI screen | Every screen in your app |
| Service | Background operations | Music playback, downloads |
| BroadcastReceiver | Respond to system events | Battery low, network changes |
| ContentProvider | Share data across apps | Contacts, media access |
| RecyclerView | Display lists | Any list of items |
| Retrofit | Network API calls | All API communication |
| Room | SQLite abstraction | Structured data storage |
| SharedPreferences | Key-value storage | Settings, preferences, login state |
🎉 Congratulations! You've Completed the Android Series! 🎉
You now have a solid foundation in Android development — from setting up Android Studio to publishing your app on the Play Store. Keep practicing, build projects, and never stop learning!
Ready to master Android Development?
Build real-world Android apps with hands-on projects, mentor-led sessions, and placement support.
.png)