0% found this document useful (0 votes)
60 views3 pages

Senior Android Developer Interview Guide

Uploaded by

osmansio
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views3 pages

Senior Android Developer Interview Guide

Uploaded by

osmansio
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Senior Android Developer Interview Prep Guide (7+ years)

1. Android Core & Lifecycle


Q1: Explain Activity, Fragment, and ViewModel lifecycle. A1: Activity: onCreate → onStart → onResume
→ onPause → onStop → onDestroy. Fragment: similar, tied to host Activity. ViewModel survives
configuration changes; tied to lifecycle owner.

Q2: Communication between Activity and Fragment? A2: Shared ViewModel scoped to Activity; LiveData
or StateFlow for reactive updates; avoid passing large objects via Bundle.

Q3: BroadcastReceiver vs ContentProvider vs Service? A3: BroadcastReceiver: event notifications;


ContentProvider: data sharing across apps; Service: background tasks, IntentService deprecated,
WorkManager preferred for background tasks.

2. Memory Management & Performance


Q4: How does Android memory management work? A4: Heap vs Stack; GC cleans unreferenced objects;
prevent leaks by avoiding static Context references, clearing listeners, using WeakReferences; tools:
LeakCanary, MAT, Profiler.

Q5: ANRs and debugging? A5: ANR occurs when main thread blocked >5s. Debug using [Link],
Profiler. Move heavy tasks to background threads or coroutines.

Q6: Optimizing startup time? A6: Lazy SDK initialization, deferred Room setup, Baseline Profiles, App
Startup library, lightweight layouts, avoid reflection-heavy DI at startup.

3. Concurrency & Coroutines


Q7: Threads vs AsyncTask vs Executor vs RxJava vs Coroutines? A7: Threads: manual; AsyncTask:
deprecated; Executor: parallel tasks; RxJava: reactive; Coroutines: structured concurrency, suspend
functions, use [Link] for background.

Q8: Long-running tasks post Android 12? A8: WorkManager for deferred tasks; ForegroundService if
immediate execution; respect battery optimization.

Q9: Coroutine scopes? A9: GlobalScope (avoid), viewModelScope (tied to VM), lifecycleScope (tied to
lifecycle), SupervisorJob for isolated error handling.

4. Database & Storage Optimization


Q10: Room optimization for large datasets? A10: Paging3 for lists, indices for queries, bulk inserts in
transactions, Flow/LiveData for reactive updates, avoid main-thread queries.

1
Q11: Data sharing across apps? A11: ContentProvider, FileProvider, AIDL/Binder for IPC, Broadcasts for
messages (beware security).

5. Networking & API Efficiency


Q12: Reduce network latency & battery usage? A12: OkHttp caching, conditional GETs, batch requests,
WorkManager for sync, GZIP/Protobuf payloads, HTTP/2 keep-alive connections.

Q13: API versioning? A13: Backward-compatible responses, feature flags, handle deprecated fields
gracefully, use sealed classes or Result wrappers.

6. UI, Graphics & Compose Optimization


Q14: Optimize RecyclerView / LazyColumn for 10k+ items? A14: Paging3, DiffUtil, ViewHolder reuse,
placeholders, snapshotFlow in Compose.

Q15: UI rendering optimization? A15: Shallow view hierarchy, ConstraintLayout, avoid overdraw, recycle
bitmaps, use remember in Compose, hardware acceleration profiling.

Q16: Custom Views drawing? A16: Override onMeasure, onLayout, onDraw, minimize object allocations
in onDraw, cache Paint objects.

7. Navigation & Architecture


Q17: Navigation Components vs Compose Navigation? A17: XML-based: nav_graph.xml, fragments,
SafeArgs; Compose: NavHost in code, composable routes, navArguments. Backstack handled by
NavController.

Q18: Multi-module project structure? A18: - app/: entry point - core/: network, DB, UI components -
domain/: models, use cases - feature/: login, profile, dashboard Dependency: app → feature → domain
→ core.

Q19: Offline-first architecture? A19: Room cache → WorkManager for sync → conflict resolution
(timestamps) → paging for large datasets → reactive UI updates.

8. Security & App Hardening


Q20: Secure sensitive data? A20: EncryptedSharedPreferences, EncryptedFile, avoid storing secrets in
APK, certificate pinning, obfuscation with R8.

Q21: Prevent reverse engineering? A21: Code obfuscation, resource shrinking, dynamic features,
runtime checks.

2
9. Debugging & Profiling
Q22: Performance bottleneck analysis? A22: Android Studio Profiler (CPU, Memory, Network), Systrace/
Perfetto for frame drops, Logcat for ANRs, Traceview for method-level profiling.

Q23: Measuring battery consumption? A23: Energy Profiler in Android Studio, ADB Battery Historian,
optimize network calls, wake locks, background jobs, test on real devices.

10. Advanced Topics


Q24: JNI / NDK usage? A24: Native code for performance-critical tasks (image processing, crypto),
reduce Java overhead.

Q25: Animations? A25: ValueAnimator vs ObjectAnimator vs Compose animation APIs, hardware-


accelerated, avoid allocations during onDraw.

Q26: Dynamic Feature Modules? A26: Split APKs for on-demand features, reduces initial download size,
enables modular development.

11. Behavioral / Leadership Questions


Q27: Prioritize features vs tech debt? A27: Assess business value vs risk, timebox tech debt fixes,
communicate trade-offs, automate tests to prevent new debt.

Q28: Mentoring juniors & ensuring code quality? A28: Code reviews, pair programming, knowledge
sharing sessions, CI/CD pipelines, documentation.

Q29: Performance improvement story? A29: STAR method: Identify issue → analyze profiler → defer
SDK init → optimize DB → reduce PNG → result: startup 6s → 2.5s, memory usage improved.

Q30: Architecture trade-off decision? A30: Example: Hilt vs manual DI for build speed vs APK size,
justified decision with trade-offs.

Visual Diagrams (to include in PDF / prep sheet)

1. Multi-module project: app → feature → domain → core (boxes & arrows)


2. Navigation flow: NavController, NavHost, composables, fragment-based flow
3. Offline-first sync: Room DB cache → WorkManager → remote API → UI

This guide can be converted into a 1–2 page PDF cheat sheet with diagrams for quick revision before
interviews.

Common questions

Powered by AI

Protecting sensitive data involves using EncryptedSharedPreferences and EncryptedFile to store sensitive information securely, avoiding hardcoding secrets in the APK, and implementing certificate pinning to prevent man-in-the-middle attacks. Code obfuscation with R8 and runtime checks also contribute to safeguarding the application against reverse engineering .

Minimizing network latency and battery usage can be achieved by implementing caching strategies such as using OkHttp caching, performing conditional GET requests, batching network calls together, and using GZIP or Protobuf to compress data payloads. Keeping connections alive with HTTP/2 and properly scheduling network operations using WorkManager also contributes to efficiency .

Optimizing RecyclerView or LazyColumn for large datasets includes using Paging3 to handle paging of data, DiffUtil to efficiently update the UI, reusing ViewHolders in RecyclerView, and using snapshotFlow in Compose for improved performance. These techniques help manage memory use, reduce UI rendering time, and improve user experience .

To prevent memory leaks, developers should avoid static references to Context, clear listeners properly, use WeakReferences where appropriate, and utilize tools like LeakCanary, Memory Analyzer Tool (MAT), and the Android Profiler to detect leaks. It is also important to manage listeners and observers' lifecycles effectively .

Activity and Fragment have similar lifecycles, starting with onCreate() and ending with onDestroy(). However, a Fragment is tied to the lifecycle of its host Activity. The ViewModel, on the other hand, is designed to survive configuration changes and is tied to the lifecycle of its lifecycle owner, rather than its lifecycle methods, ensuring data retention across configuration changes .

Optimizing app startup time can involve lazy initialization of SDKs, deferring Room database setup, using Baseline Profiles, employing the App Startup library, designing lightweight layouts, and avoiding reflection-heavy dependency injection during startup. This minimizes delays and enhances the user experience from app launch .

A multi-module project structure might involve segregating the app into modules like app, core (networking, database, UI components), domain (business logic, models, use cases), and feature (specific parts like login, profile). This structure promotes modularity, reusability, separation of concerns, and faster build times by isolating each module's build process .

WorkManager is preferred over IntentService because it provides a more robust framework for handling deferrable and guaranteed execution of background tasks, especially those that need to survive application restarts and respect battery optimization settings. IntentService is deprecated as it lacks the flexibility and capabilities regarding API levels and power constraints .

Effective API versioning strategies include designing backward-compatible responses, implementing feature flags for incremental rollouts, handling deprecated fields gracefully, and using sealed classes or Result wrappers for improved safety. These methodologies ensure that new features can be released without disrupting existing services .

Coroutines provide a modern, structured concurrency approach allowing developers to write asynchronous code using synchronous code style. With the use of Dispatchers.IO for background threads and coroutine scopes (GlobalScope, viewModelScope, lifecycleScope), developers can manage concurrent tasks efficiently. Post Android 12, WorkManager is recommended for handling long-running tasks to ensure compliance with the latest OS restrictions .

You might also like