tezvyn:

📱Mobile Dev

Mobile app development across platforms

351 bites

Android & Kotlin30 sec read

Perfetto: See Your Whole System on One Timeline

Perfetto is a flight recorder for your system, capturing kernel and app events on a single timeline. Use it to diagnose complex issues like jank by correlating app behavior with system activity.

Android & Kotlin30 sec read

Robolectric: Run Android Unit Tests on the JVM

Robolectric runs Android unit tests on a regular JVM, not a slow emulator. Use it in CI/TDD to test logic like Activity lifecycles without the minutes-long build-deploy cycle. The footgun is over-mocking; Robolectric tests behavior, not just implementation.

Android & Kotlin30 sec read

Handling API State with a Sealed Class Wrapper

Treat API calls as states, not just data. A sealed class wrapper (`Success`, `Error`, `Loading`) models these states for your UI. Use this with Retrofit to show spinners or errors without crashing. The footgun: don't scatter try-catch blocks; centralize them.

Android & Kotlin30 sec read

Kotlinx.serialization: Kotlin's Native Data Converter

Kotlinx.serialization is Kotlin's native way to convert data classes into formats like JSON. It uses a compiler plugin to automate the process, making it ideal for API calls or saving data.

Android & Kotlin30 sec read

Scoped Storage: Your App's Private File Cabinet

Scoped Storage gives your app a private file cabinet on external storage, not a key to the whole building. It's the default on modern Android for saving data or accessing media. The footgun: don't use direct file paths to shared files; you must use new.

Android & Kotlin30 sec read

Compose Layouts: Build UI by Describing It

Describe your UI, and Compose draws it. Use `Column` and `Row` to position elements, then augment them with modifiers. The footgun is coding before you've broken the visual design into reusable parts, leading to a tangled mess.

Android & Kotlin30 sec read

Android View Animation: A Blueprint for Motion

Think of Android's view-based animations as a pre-written score. You define the animation (the "score") in an XML file, then apply it to a View (the "instrument") in your code. This is used for animating properties like alpha or translation on UI elements.

Android & Kotlin30 sec read

Data Binding: Link Android UI to Data in XML

Data Binding lets you connect UI components to data sources directly in XML, eliminating manual `findViewById` calls. It's used to set view properties based on your ViewModel's state.

Android & Kotlin30 sec read

Android Foreground Services: Work the User Can See

A foreground service tells Android, "Don't kill this process; the user knows it's running." It's a contract for long-running work made visible by a persistent notification, used for music playback or navigation.

Android & Kotlin30 sec read

LiveData: Lifecycle-Aware Data Observation

LiveData is a data holder that only notifies active UI components. It connects your ViewModel's data to your UI, preventing crashes and memory leaks by respecting the Android lifecycle.

Android & Kotlin30 sec read

Android ViewModel: Survive Screen Rotations

A ViewModel is a lifecycle-aware data holder that separates your UI's state from its controller. It keeps data alive during configuration changes like screen rotations, preventing data loss and repeated network calls.

Android & Kotlin30 sec read

Android's Activity Lifecycle: A Screen's Journey

Think of an Activity's lifecycle as a stage play's script. Methods like onCreate() and onPause() are cues for your app screen to set up, appear, or hide. This manages state during interruptions like phone calls.

Android & Kotlin30 sec read

Kotlin's Type-Safe Builders: Code as Data

Type-safe builders use Kotlin code to create a custom language (DSL) for building complex objects. It's like writing HTML, but the compiler validates your structure. This is common for UI layouts or server configs. The footgun is omitting `@DslMarker`.

Android & Kotlin30 sec read

Reified Type Parameters: Accessing Generic Types at Runtime

Reified type parameters let you access generic types at runtime, bypassing JVM type erasure. In Kotlin, you use this inside `inline` functions to check types (`obj is T`) or get a class reference. The footgun: `reified` requires `inline` to work.

Android & Kotlin30 sec read

Kotlin's `in` and `out`: Declaration-Site Variance

Kotlin's `out` and `in` keywords define a generic class as a producer or consumer at its declaration, avoiding Java's repetitive wildcards. Use `out T` for types only returned (produced) and `in T` for types only consumed.

Android & Kotlin30 sec read

SharedFlow: A Hot Flow for Broadcasting Events

A SharedFlow is a hot stream that broadcasts values to all subscribers, like a live TV channel. It's ideal for one-to-many events, like UI updates or notifications. The main footgun: it never completes, so `collect` will suspend forever.

Android & Kotlin30 sec read

Kotlin Delegated Properties: Reusing Getter/Setter Logic

Kotlin's delegated properties let you outsource a property's getter/setter logic. Instead of writing boilerplate, you reuse common patterns like lazy initialization (`by lazy`) or observing changes (`by observable`).

Android & Kotlin30 sec read

Structured Concurrency in Kotlin

Structured concurrency treats async operations like code blocks: a parent task's lifetime contains its children. In Kotlin, a `CoroutineScope` ensures if the parent is cancelled, all its child coroutines are too.

Android & Kotlin30 sec read

Kotlin Flow: Asynchronous Data Streams

A Kotlin Flow is like an async Sequence, emitting multiple values over time without blocking. It's used for live data from a database or streaming network responses. The footgun: Flows are cold; the code doesn't run until a collector calls `.collect()`.

Android & Kotlin30 sec read

CoroutineScope: The Parent of Your Coroutines

A CoroutineScope acts as a parent to a group of coroutines, managing their lifecycles. When the parent scope is cancelled, all its children are cancelled too. It's used with builders like `launch` to group related work, like in an Android ViewModel.