Posts

Showing posts with the label Battery Optimization

Cracking Android SDE2/SDE3 Interviews in 2026: Deep Dives, Code, Follow-ups | Part-6

Image
  In this part of Android Interview Questions Series, I’ll be talking about teh questions related to Data & Networking.   61. Retrofit + Paging3? Interviewer How do you integrate Retrofit with Paging 3 to build an infinite scrolling list? Senior-Level Answer (Production-Oriented) In production, Paging 3 + Retrofit is used to stream paginated network data efficiently while controlling memory, network usage, and UI jank . The architecture typically has three layers : PagingSource → Network-only pagination RemoteMediator → Network + Room (offline-first) Pager → Orchestrates paging, caching, and lifecycle awareness When to use which Network PagingSource (Retrofit → UI) Why PagingSource Limits in-memory items to ~2–3 pages (~60–100 objects) Prevents RecyclerView holding thousands of objects Reduces GC pressure by ~40–60% vs manual pagination Example: Users PagingSource class UserPagingSource ( private val api: UserApi ) : PagingSource< Int , User...