<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amitdogra on Medium]]></title>
        <description><![CDATA[Stories by Amitdogra on Medium]]></description>
        <link>https://medium.com/@amitdogra70512?source=rss-fd24f16b288------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xWiG5CB7h9FKHlTK7LmBtg.jpeg</url>
            <title>Stories by Amitdogra on Medium</title>
            <link>https://medium.com/@amitdogra70512?source=rss-fd24f16b288------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 15:25:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amitdogra70512/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mastering — by lazy in Kotlin]]></title>
            <link>https://medium.com/@amitdogra70512/mastering-by-lazy-in-kotlin-93023b05e66d?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/93023b05e66d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-delegates]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 10:53:13 GMT</pubDate>
            <atom:updated>2026-03-17T10:53:13.229Z</atom:updated>
            <content:encoded><![CDATA[<p>A deep dive into lazy initialization, delegation, thread-safety modes, and how Kotlin implements it under the hood.</p><p>If you’ve written Kotlin for Android, you’ve almost certainly seen:</p><pre>val viewModel by viewModel()<br>val binding by lazy { FragmentRoomBinding.inflate(layoutInflater) }</pre><blockquote>But what exactly is <strong>by lazy</strong>?<br>Is it just syntactic sugar — or something deeper?</blockquote><p>In this blog, we’ll go <strong>beyond basics</strong> and understand:</p><ul><li>What by lazy really is</li><li>How it works internally</li><li>Thread-safety modes</li><li>Performance implications</li><li>When to use it (and when NOT to)</li></ul><h3>What is by lazy?</h3><p>by lazy is a <strong>property delegate</strong> in Kotlin that <strong>initializes a value only when it&#39;s first accessed</strong>.</p><pre>val data by lazy {<br>    println(&quot;Initializing...&quot;)<br>    &quot;Hello World&quot;<br>}</pre><pre>println(data) // Initializes here<br>println(data) // Reuses cached value</pre><p>Output:</p><pre>Initializing...<br>Hello World<br>Hello World</pre><p>👉 Initialization happens <strong>only once</strong>, and result is <strong>cached</strong>.</p><h3>What’s happening under the hood?</h3><p>When you write:</p><pre>val data by lazy { ... }</pre><p>Kotlin converts it roughly into:</p><pre>val dataDelegate = lazy { ... }<br><br>val data: String<br>    get() = dataDelegate.value</pre><p>So:</p><ul><li>lazy {} returns a Lazy&lt;T&gt; object</li><li>.value triggers computation</li></ul><p>And inside value:</p><pre>if (not initialized) {<br>    initialize (based on mode) //see below: custom implementation of - by lazy {}<br>}<br>return cached value</pre><h3>Inside Lazy&lt;T&gt;</h3><p>Simplified version of Kotlin’s implementation:</p><pre>/**<br> * Represents a value with lazy initialization.<br> *<br> * To create an instance of [Lazy] use the [lazy] function.<br> */<br>public interface Lazy&lt;out T&gt; {<br>    /**<br>     * Gets the lazily initialized value of the current Lazy instance.<br>     * Once the value was initialized it must not change during the rest of lifetime of this Lazy instance.<br>     */<br>    public val value: T<br><br>    /**<br>     * Returns `true` if a value for this Lazy instance has been already initialized, and `false` otherwise.<br>     * Once this function has returned `true` it stays `true` for the rest of lifetime of this Lazy instance.<br>     */<br>    public fun isInitialized(): Boolean<br>}</pre><p>Internally, it stores:</p><ul><li>A flag (initialized or not)</li><li>The computed value</li></ul><h3>Thread Safety Modes</h3><pre>val data by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { ... }</pre><p>There are <strong>3 modes</strong>:</p><h4>1. SYNCHRONIZED (default)</h4><pre>lazy { ... } // SYNCHRONIZED → uses locks (synchronized)</pre><ul><li>Thread-safe</li><li>Only one thread initializes</li><li>Uses locking</li></ul><p>👉 Best for multi-threaded environments</p><h4>2. PUBLICATION</h4><pre>lazy(LazyThreadSafetyMode.PUBLICATION) { ... } //PUBLICATION → uses CAS (compareAndSet)</pre><ul><li>Multiple threads may initialize</li><li>Only one result is used</li><li>Less locking → better performance</li></ul><p>👉 Trade-off between safety &amp; speed</p><h4>3. NONE</h4><pre>lazy(LazyThreadSafetyMode.NONE) { ... }</pre><ul><li>No synchronization</li><li>Not thread-safe</li><li>Fastest</li></ul><p>👉 Best for:</p><ul><li>Android main thread</li><li>UI-only properties</li></ul><pre>/**<br> * Specifies how a [Lazy] instance synchronizes initialization among multiple threads.<br> */<br>public enum class LazyThreadSafetyMode {<br><br>    /**<br>     * Locks are used to ensure that only a single thread can initialize the [Lazy] instance.<br>     */<br>    SYNCHRONIZED,<br><br>    /**<br>     * Initializer function can be called several times on concurrent access to uninitialized [Lazy] instance value,<br>     * but only the first returned value will be used as the value of [Lazy] instance.<br>     */<br>    PUBLICATION,<br><br>    /**<br>     * No locks are used to synchronize an access to the [Lazy] instance value; if the instance is accessed from multiple threads, its behavior is undefined.<br>     *<br>     * This mode should not be used unless the [Lazy] instance is guaranteed never to be initialized from more than one thread.<br>     */<br>    NONE,<br>}</pre><h3>Real Android Use Cases</h3><h4>ViewBinding in Fragment</h4><pre>private val binding by lazy {<br>    FragmentRoomBinding.inflate(layoutInflater)<br>}</pre><p>Avoids:</p><ul><li>unnecessary inflation</li><li>null checks</li></ul><h4>Expensive object creation</h4><pre>val database by lazy {<br>    Room.databaseBuilder(...).build()<br>}</pre><p>Only created when needed.</p><h4>Heavy computation</h4><pre>val sortedList by lazy {<br>    bigList.sorted()<br>}</pre><h3>❌ When NOT to use by lazy</h3><h4>When value must change</h4><pre>val count by lazy { 10 }</pre><p><strong>Imp</strong> — You can’t reassign it.</p><h4>Lifecycle-dependent objects</h4><pre>val binding by lazy { ... } // ❌ in Fragment (wrong usage)</pre><p>Why?</p><ul><li>Fragment view gets destroyed</li><li>lazy keeps reference → memory leak</li></ul><p>👉 Use nullable binding instead.</p><h4>Cheap objects</h4><pre>val x by lazy { 5 }</pre><p>Unnecessary overhead.</p><h3>Delegation — The Bigger Concept</h3><p>by lazy is part of <strong>property delegation</strong>.</p><p>General form:</p><pre>val prop by delegate</pre><p>Delegate must implement:</p><pre>operator fun getValue(...)</pre><h3>Custom <em>by lazy{ } </em>Implementation:</h3><pre>class MyLazy&lt;T : Any&gt;(val initializer: () -&gt; T)  {<br>     private var value :Any? = null<br><br>     operator fun getValue(thisRef: Any?, property: KProperty&lt;*&gt;) : T {<br>          if(value == null){<br>               // println(property.name) - this will print --&gt; lazyName<br>               value = initializer()<br>          }<br>          return value as T<br>     }<br>}<br><br>fun main() {<br>     val lazyName by MyLazy { // getValue() will be invoked everytime we access lazyName<br>          println(&quot;lazy initialisation&quot;)<br>          &quot;amit kumar&quot;<br>     }<br>     println(lazyName)<br>     println(lazyName)<br>}<br><br>// output:<br>lazy initialisation<br>amit kumar<br>amit kumar<br><br>// Note: <br>This implementation is equivalent to LazyThreadSafetyMode.NONE:<br>- No thread safety<br>- No visibility guarantees<br>- Suitable only for single-thread usage</pre><h3>Other Built-in Delegates</h3><h4>Delegates.observable</h4><p>Calls a specified callback function when property changes</p><pre>var name by Delegates.observable(&quot;Initial&quot;) { _, old, new -&gt;<br>    println(&quot;$old → $new&quot;)<br>}</pre><h4>Delegates.vetoable</h4><p>It lets you <strong>control whether a value change is allowed or not</strong>.</p><p>Before the value changes:</p><p>A <strong>callback runs</strong></p><p>You decide:</p><ul><li>✅ true → allow change</li><li>❌ false → reject change</li></ul><pre>var age by Delegates.vetoable(18) { _, _, new -&gt;<br>    new &gt;= 18<br>}<br><br><br>// Meaning:<br>Initial value = 18<br><br>If someone tries to update:<br>  If new &gt;= 18 → allowed ✅<br>  Else → ignored ❌<br><br>// Example <br>age = 20  // ✅ allowed → age = 20<br>age = 15  // ❌ rejected → age stays 20</pre><h4>Delegates.notNull()</h4><pre>var value: String by Delegates.notNull()</pre><p>Throws exception if accessed before initialization.</p><h3>Performance Considerations</h3><ul><li>lazy adds:</li><li>object allocation</li><li>synchronization (depending on mode)</li></ul><h3>Best Practices</h3><ul><li>Use lazy for <strong>expensive or deferred initialization</strong></li><li>Prefer LazyThreadSafetyMode.NONE in Android UI <em>(Android UI runs on a single thread → no need for synchronization → avoid overhead)</em></li><li>Avoid in lifecycle-sensitive components</li><li>Don’t overuse for trivial values</li></ul><h3>💡Interview Insight</h3><blockquote><em>by lazy is a property delegate that defers initialization until first access and caches the result. It improves performance by avoiding unnecessary computation and supports different thread-safety modes depending on the use case.</em></blockquote><h3>Final Takeaway</h3><p>Think of by lazy as:</p><blockquote><em>“Compute this value only when needed, once, and remember it forever.”</em></blockquote><p>It’s simple on the surface, but deeply connected to:</p><ul><li>delegation</li><li>concurrency</li><li>memory optimization</li></ul><p>If you truly understand lazy, you also understand:</p><ul><li>how Kotlin manages properties</li><li>how Android apps optimize performance</li><li>how to write cleaner, safer code</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93023b05e66d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Side-Effects in Jetpack Compose — A Deep Dive]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/side-effects-in-jetpack-compose-a-deep-dive-a5f9602e1640?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/2600/1*VAN_2ywOxVD5d8ze6n-4Ng.png" width="2704"></a></p><p class="medium-feed-snippet">Why do side-effect handlers exist in Compose at all?</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/side-effects-in-jetpack-compose-a-deep-dive-a5f9602e1640?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/side-effects-in-jetpack-compose-a-deep-dive-a5f9602e1640?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5f9602e1640</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[compose]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 09:23:31 GMT</pubDate>
            <atom:updated>2026-02-23T11:35:35.680Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Kotlin: Inline Keyword]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/kotlin-inline-keyword-3ee87f4418b9?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/2006/1*cZiRy156AGjaLwd7mAlMkA.png" width="2006"></a></p><p class="medium-feed-snippet">Why inline exists, how it works internally, when to use it, and common pitfalls, with real-world Android examples.</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/kotlin-inline-keyword-3ee87f4418b9?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/kotlin-inline-keyword-3ee87f4418b9?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ee87f4418b9</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[inline]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 08:56:36 GMT</pubDate>
            <atom:updated>2026-02-12T08:56:36.961Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Launch Modes in Android]]></title>
            <link>https://medium.com/@amitdogra70512/launch-modes-in-android-764998e4e35e?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/764998e4e35e</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-launch-mode]]></category>
            <category><![CDATA[activity-launch-mode]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 08:22:43 GMT</pubDate>
            <atom:updated>2025-12-01T08:22:43.048Z</atom:updated>
            <content:encoded><![CDATA[<p>Breakdown of all launch modes with examples, diagrams</p><p>Activities are the core building blocks of every app’s UI.<br> But launching an Activity is not as simple as calling startActivity().<br> Behind the scenes, Android must decide:</p><ul><li>Should it create a <strong>new instance</strong> of the Activity?</li><li>Can it <strong>reuse an existing one</strong>?</li><li>Should it open in the <strong>same task</strong> or a <strong>different task</strong>?</li><li>Should it <strong>clear part of the back stack</strong>?</li></ul><p>This is where <strong>Launch Modes</strong> come in.</p><p>Android’s Activity launch modes control <strong>how Activities are created</strong>, <strong>how many instances exist</strong>, and <strong>how they behave inside a task (back stack)</strong>.</p><p>In this guide, we’ll break down each launch mode — standard, singleTop, singleTask, singleInstance, and singleInstancePerTask—along with taskAffinity, using clear examples and intuitive stack diagrams.</p><h3>What is a Task 🤔?</h3><p>A <strong>task</strong> is a <strong>stack of Activities, </strong>placed one above another</p><ul><li>Pressing Back pops the top Activity</li><li>Each task behaves like a separate “space” of navigation</li></ul><p>A <strong><em>task</em></strong> is a collection of activities that users interact with when trying to do something in your app. These activities are arranged in a stack called the <strong><em>back stack</em></strong> in the order in which each activity is opened.</p><blockquote>Imp: Read more about <a href="https://developer.android.com/guide/components/activities/tasks-and-back-stack">Tasks and the back stack.</a></blockquote><h3>1. Standard Launch Mode (default)</h3><p>Every time you launch an Activity, a <strong>new instance</strong> is created and pushed on top of the task.</p><h4>Flow</h4><ol><li>Launch A → Stack: [A]</li><li>From A ➝ launch B → Stack: [A, B]</li><li>From B ➝ launch A → Stack: [A, B, A] (new instance)</li><li>Relaunch A again → Stack: [A, B, A, A]</li></ol><h4>Key Points</h4><ul><li>Always creates a <strong>new instance</strong></li><li>onCreate() called every time</li><li>Can create multiple copies of same Activity</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIuwYZ-c_z4poBExeGna_g.png" /></figure><h4>Problem</h4><p>Sometimes you don’t want duplicate instances.<br>For example: clicking a notification multiple times reopens the same screen repeatedly.</p><p>Solution → singleTop.</p><h3>2. SingleTop</h3><p>If the Activity is <strong>already the top of the stack</strong>, Android <strong>reuses the same instance</strong> instead of creating a new one.</p><h4>Flow:</h4><p>Stack: [A] (A is singleTop)</p><p>From A ➝ Launch A again:</p><ul><li>Standard: [A, A]</li><li>singleTop: [A] (no new instance)</li></ul><p>But if A is <strong>not</strong> on top:</p><p>Stack: [A, B]</p><p>From B ➝ launch A:</p><ul><li>Even with singleTop: [A, B, A] (new instance)</li></ul><blockquote>What if we want only one Instance of Activity per task / stack?</blockquote><blockquote>Ans: <strong>SingleInstance</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1JZN2eUp1mtHmbYMck9KLQ.png" /></figure><p><strong>UseCase</strong>: Notification click → open same screen without duplicates</p><h3>3. SingleTask</h3><p>Only <strong>one instance</strong> of this Activity is allowed in <strong>any particular task</strong>.</p><p>If you try launching it again:</p><ul><li>If it already exists <strong>in the same task</strong> → Android brings that existing instance to the top (and clears everything above it)</li><li>If it does NOT exist in that task → <strong>new instance created</strong></li></ul><p>singleTask behaviors change depending on <strong>taskAffinity.</strong></p><h4>Understanding taskAffinity</h4><p>Each Activity belongs to a “task group”.</p><p>If two Activities:</p><ul><li>share the same affinity → they can live in the same task</li><li>have different affinities → they will be placed in different tasks</li></ul><p>Default affinity = App package.</p><p>You can override:</p><pre>android:taskAffinity=&quot;com.example.myAffinity&quot;</pre><blockquote><strong>taskAffinity</strong>: does it stay inside your app’s task or create its OWN task?</blockquote><h4>a. singleTask WITH custom taskAffinity</h4><pre>A → standard  <br>B → singleTask + taskAffinity=&quot;com.example.special&quot;<br>C → standard<br>D → standard</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nfwkVtuAxY6Inl48zZTxew.png" /></figure><h4>Flow:</h4><ol><li>Launch A<br> Task1: [A]</li><li>Launch B from A<br> B has different affinity → goes to <strong>Task2</strong><br> Task1: [A]<br> Task2: [B]</li><li>Launch C from B<br> C has no affinity → joins B<br> Task2: [B, C]</li><li>Launch D from C<br> Task2: [B, C, D]</li><li>From D → launch B again<br> B already exists in Task2 → Android <strong>pops C and D</strong><br> Task1: [A]<br> Task2: [B] ← B brought to front, task cleaned</li></ol><h4><strong>b. singleTask WITHOUT taskAffinity</strong> (default case)</h4><pre>A → standard  <br>B → singleTask  <br>C → standard<br>D → standard</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EwjKS3CApr6W4mDcKZnQYg.png" /></figure><h4>Flow:</h4><ol><li>Launch A [A]</li><li>Launch B [A, B]</li><li>Launch C [A, B, C]</li><li>Launch D[A, B, C, D]</li><li>Launch B from D<br>Existing B located below D and C→ everything above B is removed<br>Final stack:<br>[A, B]</li></ol><h3>4. SingleInstance <strong>(Old, very restrictive)</strong></h3><p>The Activity must live <strong>alone</strong> in its <strong>own isolated task</strong>.</p><ul><li>No other Activities are allowed in that task</li><li>Always only 1 instance globally</li><li>Any Activity launched from it goes to a <strong>different task</strong></li></ul><pre>A → standard  <br>B → standard <br>C → singleInstance</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcVuKfe4TIYTfunGp3-T7A.png" /></figure><h4>Flow:</h4><ol><li>Launch A [A]</li><li>Launch B [A, B]</li><li>Launch C Task1 — [A,B] Task2-[C] (Task2 will be in Foreground now)</li><li>Launch A from C<br>A cannot be put on Task2, it will be pushed on Task1. Task1 will be in focus now.<br>Final stack: Task1-[A, B, A] Task2-[C]</li></ol><h3>Problems with singleInstance:</h3><ul><li>Too isolated, No other activities allowed in that task</li><li>Breaks normal navigation</li><li>Not good for multi-screen flows</li><li>Mostly deprecated use cases (Camera, Maps older versions)</li></ul><p>That’s why Google introduced <strong>singleInstancePerTask</strong>.</p><h3>SingleInstancePerTask</h3><p>Hybrid between singleTask and singleInstance</p><ul><li>Each instance runs in its <strong>own task</strong></li><li>That task contains <strong>only that Activity</strong></li><li>But activities launched from it are not forced into weird tasks</li><li>Supports normal navigation better</li></ul><p>This mode is newer and fixes the problems of old singleInstance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03-fzhsRv3__Arm8sqtenA.png" /></figure><h4>Flow:</h4><ol><li>Launch A [A]</li><li>Launch B [A, B]</li><li>Launch C Task1 — [A,B] Task2-[C] (Task2 will be in Foreground now)</li><li>Launch A from C<br>A will be put on Task2, it will be pushed on Task2. <br>Final stack: Task1-[A, B] Task2-[C, A]</li></ol><h3>Summary</h3><h4>standard (default)</h4><ul><li>Always creates a <strong>new instance</strong></li><li>Multiple copies of the same Activity can exist</li><li>Best for normal screens</li></ul><h4>singleTop</h4><ul><li>Reuses instance <strong>only if it’s already on top</strong></li><li>Prevents duplicate screens (e.g., Home, Notifications)</li></ul><h4>singleTask</h4><ul><li>Only <strong>one instance per task</strong></li><li>If launched again, Android brings the existing instance to top and clears anything above it</li><li>Works closely with <strong>taskAffinity</strong></li></ul><h4>taskAffinity</h4><ul><li>Defines <strong>which task</strong> an Activity prefers to live in</li><li>Changing affinity can move Activities to their own task or join another task</li></ul><h4>singleInstance (legacy, too restrictive)</h4><ul><li>Activity lives <strong>alone</strong> in its own isolated task</li><li>Only one global instance</li><li>Other Activities cannot join the same task</li><li>Not recommended anymore</li></ul><h4>singleInstancePerTask (modern &amp; flexible)</h4><ul><li>One instance <strong>per task</strong>, but not globally unique</li><li>Still lives alone in its task</li><li>More compatible with modern navigation</li></ul><p>And taskAffinity decides <strong>which task</strong> an Activity wants to live in.</p><p>Happy Coding !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=764998e4e35e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SharedFlow vs StateFlow vs LiveData — The Simplest Explanation for Android Developers]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/sharedflow-vs-stateflow-vs-livedata-the-simplest-explanation-for-android-developers-f7b39976ed39?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/1280/1*g_7c3xlrNC0HhV5hgxITIA.png" width="1280"></a></p><p class="medium-feed-snippet">Choosing Between SharedFlow, StateFlow &amp; LiveData Just Got Easier</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/sharedflow-vs-stateflow-vs-livedata-the-simplest-explanation-for-android-developers-f7b39976ed39?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/sharedflow-vs-stateflow-vs-livedata-the-simplest-explanation-for-android-developers-f7b39976ed39?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7b39976ed39</guid>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[kotlin-stateflow]]></category>
            <category><![CDATA[kotlin-flow]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin-sharedflow]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Tue, 18 Nov 2025 14:54:26 GMT</pubDate>
            <atom:updated>2025-11-18T14:56:43.530Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stop Misusing CoroutineExceptionHandler — Exception Handling in Coroutines]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/stop-misusing-coroutineexceptionhandler-exception-handling-in-coroutines-bbf3c0798ade?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/1024/1*CLedavLvJQd5ta99QcV-pg.png" width="1024"></a></p><p class="medium-feed-snippet">Understanding Coroutine Exception Propagation: launch, async, SupervisorJob, and CoroutineExceptionHandler Explained</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/stop-misusing-coroutineexceptionhandler-exception-handling-in-coroutines-bbf3c0798ade?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/stop-misusing-coroutineexceptionhandler-exception-handling-in-coroutines-bbf3c0798ade?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbf3c0798ade</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[exception-handling]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Sat, 01 Nov 2025 15:16:56 GMT</pubDate>
            <atom:updated>2025-11-02T05:34:49.425Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding Android Architecture: MVC, MVP, MVVM & MVI Explained with Code]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/understanding-android-architecture-mvc-mvp-mvvm-mvi-explained-with-code-21c5fb9336ab?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/986/1*0sTjQg2T4Dm4ya_Je3fbpg.png" width="986"></a></p><p class="medium-feed-snippet">Discover how MVC, MVP, MVVM, and MVI shape Android app structure&#x200A;&#x2014;&#x200A;clear explanations, modern patterns, and practical examples for&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/understanding-android-architecture-mvc-mvp-mvvm-mvi-explained-with-code-21c5fb9336ab?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/understanding-android-architecture-mvc-mvp-mvvm-mvi-explained-with-code-21c5fb9336ab?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/21c5fb9336ab</guid>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 17:30:00 GMT</pubDate>
            <atom:updated>2025-10-27T17:30:00.051Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Inside Android Animations: How Handler and Looper Drive Every Frame]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/inside-android-animations-how-handler-and-looper-drive-every-frame-337d8728dc83?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/1024/1*M7Ii0h4JwTKMOv7IxemL6A.png" width="1024"></a></p><p class="medium-feed-snippet">Handler and Looper power Android animations&#x200A;&#x2014;&#x200A;Looper runs the loop, Handler posts timed UI updates, creating smooth, frame-by-frame motion.</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/inside-android-animations-how-handler-and-looper-drive-every-frame-337d8728dc83?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/inside-android-animations-how-handler-and-looper-drive-every-frame-337d8728dc83?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/337d8728dc83</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Sat, 18 Oct 2025 07:35:51 GMT</pubDate>
            <atom:updated>2025-10-25T09:29:15.251Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Enhancing Playback: Player Listeners in Media3 ExoPlayer]]></title>
            <link>https://medium.com/@amitdogra70512/enhancing-playback-player-listeners-in-media3-exoplayer-53880c3955f6?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/53880c3955f6</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[playback]]></category>
            <category><![CDATA[media3]]></category>
            <category><![CDATA[exoplayer]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 15:39:41 GMT</pubDate>
            <atom:updated>2025-03-01T15:39:41.807Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Media3 ExoPlayer</strong> provides a powerful <strong>Player.Listener</strong> interface that allows us to track various events like playback state changes, errors, buffering and more.</p><p>In this blog, we’ll explore how to:</p><ul><li>Add and implement <strong>player listeners</strong> in Media3 ExoPlayer.</li><li>Handle <strong>playback state changes</strong>.</li><li>Capture <strong>metadata and subtitle updates</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jakmHX-Q3zotajEn" /></figure><h3>Step 1: Implementing Core Playback Functions</h3><p>Before adding listeners, let’s define basic playback functions like <strong>play, pause, stop, seek, volume control, and live playback handling</strong>.</p><pre>override fun play() {<br>    player?.play()<br>}<br>override fun pause() {<br>    player?.pause()<br>}<br>override fun stop() {<br>    player?.stop()<br>}<br><br>override fun isPlaying() = player?.playWhenReady ?: false<br><br>override fun seek(value: Double) {<br>    player?.seekTo(value.toLong())<br>}<br><br>override fun setVolume(volume: Int) {<br>    player?.volume = volume.toFloat()<br>}<br><br>override fun isMuted() = player?.volume == 0f<br><br>override fun mute() {<br>    player?.volume = 0f<br>}<br><br>override fun unMute() {<br>    player?.volume = 1f<br>}<br><br>override fun isLive(): Boolean {<br>    return player?.isCurrentMediaItemLive ?: false<br>}<br><br>override fun skipToLive() {<br>    if (isLive()) {<br>        player?.seekToDefaultPosition()<br>    }<br>}<br><br>override fun getCurrentTime(): Double = player?.currentLiveOffset?.toDouble() ?: 0.0<br><br>override fun getDuration(): Double = player?.duration?.toDouble() ?: 0.0</pre><h3>Step 2: Adding Player Listeners</h3><p>To track playback events, we add a <strong>Player.Listener</strong> to the ExoPlayer instance.</p><pre>private fun addPlayerListeners() {<br>    player?.addListener(object : Player.Listener {<br>        override fun onRenderedFirstFrame() {<br>            subtitleList.clear()<br>            startProgressUpdaterJob()<br>            mPlayerEventListener?.onRenderFirstFrame()<br>            logVSTStageEvent()<br>            isFirstFrameRendered = true<br>            convivaAnalytics.logPlaybackMetric(VideoAnalyticsConstants.PLAYER_STATE_PLAYING, 0)<br>        }<br><br>        override fun onPlayerError(error: PlaybackException) {<br>           // handle playback errors<br>       <br>        }<br>        override fun onPlayerStateChanged(playWhenReady: Boolean, state: Int) {<br>            when (state) {<br>                Player.STATE_BUFFERING -&gt; {<br>                    mPlayerEventListener?.onPlayerStateChange(PlayerState.BUFFERING_START)<br>                }<br>                Player.STATE_READY -&gt; {<br>                    mPlayerEventListener?.onPlayerStateChange(PlayerState.PLAYING)<br>                }<br>                Player.STATE_ENDED -&gt; {<br>                    mPlayerEventListener?.onPlayerStateChange(PlayerState.ENDED)<br>                }<br>                Player.STATE_IDLE -&gt; {<br>                    mPlayerEventListener?.onPlayerStateChange(PlayerState.STATE_IDLE)<br>                }<br>            }<br>        }<br>    })<br>}</pre><h3>Key Events Handled in Listeners:</h3><ul><li><strong>onRenderedFirstFrame()</strong> → Called when the first frame is displayed.</li><li><strong>onPlayerError()</strong> → Handles playback errors.</li><li><strong>onPlayerStateChanged()</strong> → Tracks buffering, ready, ended, and idle states.</li></ul><h3>Step 3: Handling Metadata and Subtitle Updates</h3><p>To process <strong>subtitle cues and metadata</strong>, use:</p><pre>override fun onCues(cues: List&lt;Cue&gt;) {<br>  if (cues.isNotEmpty()) {<br>          val subtitleText = cues.filter { !it.text.isNullOrEmpty() }<br>              .joinToString(separator = &quot; &quot;) { it.text.toString() }<br>          if (subtitleText.isNotEmpty()) {<br>              subtitleList.clear()<br>              subtitleList.add(subtitleText)<br>              mPlayerEventListener?.onSubTitlesUpdate(subtitleList)<br>          }<br>      } else {<br>          clearAndHideSubtitle()<br>      }<br>  }<br>  override fun onMetadata(metadata: Metadata) {<br>      super.onMetadata(metadata)<br>      for (i in 0 until metadata.length()) {<br>          val entry = metadata[i]<br>          // handle this<br>      }<br>  }</pre><ul><li><strong>onCues()</strong> → Updates subtitles dynamically.</li><li><strong>onMetadata()</strong> → Processes metadata</li></ul><h3>Conclusion</h3><p>In this blog, we explored <strong>how to enhance Media3 ExoPlayer playback using Player Listeners</strong>: ✅ <strong>Added core playback functions</strong> like play, pause, stop, volume, and seeking.<br> ✅ <strong>Implemented Player Listeners</strong> to track playback state, errors, and buffering.<br> ✅ <strong>Handled metadata and subtitle updates dynamically.</strong></p><h4><strong>Next Up:</strong> <strong>We’ll dive into building a custom data source for Media3, enabling playback from files, UDP multicast, and more. Stay tuned for more exciting enhancements!</strong> 🎬</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53880c3955f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Media3 ExoPlayer: Selecting Audio, Video & Subtitle Tracks]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@amitdogra70512/understanding-media3-exoplayer-selecting-audio-video-subtitle-tracks-f32bcd1e88b4?source=rss-fd24f16b288------2"><img src="https://cdn-images-1.medium.com/max/1024/0*Q6vU_hmCCBZQz3Vj" width="1024"></a></p><p class="medium-feed-snippet">Understanding Track Selection in ExoPlayer, dynamically switch between available audio, video, and subtitle tracks.</p><p class="medium-feed-link"><a href="https://medium.com/@amitdogra70512/understanding-media3-exoplayer-selecting-audio-video-subtitle-tracks-f32bcd1e88b4?source=rss-fd24f16b288------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@amitdogra70512/understanding-media3-exoplayer-selecting-audio-video-subtitle-tracks-f32bcd1e88b4?source=rss-fd24f16b288------2</link>
            <guid isPermaLink="false">https://medium.com/p/f32bcd1e88b4</guid>
            <category><![CDATA[exoplayer]]></category>
            <category><![CDATA[media3]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Amitdogra]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 15:22:41 GMT</pubDate>
            <atom:updated>2025-03-01T15:22:41.485Z</atom:updated>
        </item>
    </channel>
</rss>