Android Interview Questions Series — Part II— Android, DI
Part I link : Android Interview Questions Series — Part I — Core Java, Multithreading and Kotlin
Android Basics
- Android Application components: Activities, Services, Broadcast Receivers, Content Providers
- Activity LifeCycle, Fragment LifeCycle
- Fragment Lifecycle during Fragment Transaction
- Task Affinity, Launch Modes: The task that the activity has an affinity for. Activities with the same affinity conceptually belong to the same task (to the same “application” from the user’s perspective). The affinity of a task is determined by the affinity of its root activity. Launch Modes: “
standard
"
"singleTop
"
"singleTask
"
"singleInstance
"
5. Retention fragment- setRetainInstance(true): The Fragment’s state will be retained (and not destroyed!) across configuration changes (e.g. screen rotate). The state will be retained even if the configuration change causes the “parent” Activity to be destroyed. However, the view of the Fragment gets destroyed. setRetainInstance(true) is especially useful for long-running operations inside Fragments that do not care about configuration changes.
6. Headless fragment: Regular Fragment that returns null in onCreateView() and have setRetainInstance(true) in onCreate()
7. What is Async Task
8. Retaining Async Task while configuration change: host your AsyncTask
inside a Fragment
, call setRetainInstance(true)
on the Fragment
, and report the AsyncTask
's progress/results back to it's Activity
through the retained Fragment
9. Serialization vs Parcelable
11. What are content providers: Content providers can help an application manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps
12. Intent vs sticky Intent vs pending Intent
13. Implicit intent vs Explicit intent
14. Background service, Foreground Service and Bound Service
15 Lifecycle of Service — bound and Intent
16. What is Intent Service
18. Internal Working of RecylerView
19. setRecycledViewPool method in RecyclerView: In the case of nested recyclerView
20. Communication between Services and Activity
21. Communication between Two fragments
22. Bound Service using Messenger
23. What is BroadCast Reciever? Local vs global BroadCastreciever: Broadcast receiver is an Android component that allows you to send or receive Android system or application events.
24. Looper, Handler, and Handler Thread
25. Understanding Memory Leaks
26. Firebase Performance Monitoring
Architecture Components
- What are Android Architecture components: Android architecture components are a collection of libraries that help you design robust, testable, and maintainable apps.
- What are ViewModel and How do they work on Android? : Aclass is designed to store and manage UI-related data in a lifecycle conscious way. The
ViewModel
class allows data to survive configuration changes such as screen rotations. - What is LiveData?: It is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services.
- How ViewModels are Retained?
- What is Data Binding: It helps in declaratively binding UI elements to in our layout to data sources of our app
- Difference b/w MVP, MVC, MVVM Design patterns
- How to make Presenter of MVP, lifecycle Aware
- Explain Live Data TransFormations
- Explain WorkManger: It manages every background jobs in Android with the circumstances we choose
- Explain Room Persistence Library: It is an SQLite object mapping library. Use it to Avoid boilerplate code and easily convert SQLite table data to Java objects
- Explain App Architecture, Explain Clean Architecture in detail.
- Battery Optimisation Technique for Android App
Dependency Injection(Refer this blog)
- What is Dependency Injection and Why to do that? : Reduced Dependencies:Classes often require references to other classes. For example, a
Car
class might need a reference to anEngine
class. These required classes are called dependencies, and in this example theCar
class is dependent on having an instance of theEngine
class to run. Advantages: Reduced Dependency Carrying, More Reusable Code, More Testable Code, More Readable Code - Explain Dagger component, module, provider, scope, subcomponent, etc
- How to Inject values at run time in dagger
- What is Custom Scope in dagger
- What is the difference between @Provides and @Binds statement
- Component Vs Subcomponent: Component dependencies — Use this when you want to keep two components independent. Subcomponents — Use this when you want to keep two components coupled.
- Can a subcomponent have multiple parents: No
- Dependent component and Subcomponent
- Dagger — hilt
Part I link : Android Interview Questions Series — Part I — Core Java, Multithreading and Kotlin
References: Geeks for Geeks, Tutorials Point and, StackOverflow, Wikipedia, Edureka,MindOrks