<?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[Android in MindOrks on Medium]]></title>
        <description><![CDATA[Latest stories tagged with Android in MindOrks on Medium]]></description>
        <link>https://medium.com/mindorks/tagged/android?source=rss----f1a763fc7443--android</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Android in MindOrks on Medium</title>
            <link>https://medium.com/mindorks/tagged/android?source=rss----f1a763fc7443--android</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:47:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/mindorks/tagged/android" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <item>
            <title><![CDATA[Coroutines and Dispatchers]]></title>
            <link>https://medium.com/mindorks/coroutines-and-dispatchers-b559094b828e?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/b559094b828e</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Bigyan Thapa]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 06:48:00 GMT</pubDate>
            <atom:updated>2024-10-16T06:48:00.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwGCLQ2qqBwzHegoGYDgNg.jpeg" /></figure><p>In Android development, coroutines are commonly launched from <em>ViewModel</em> classes using <em>viewModelScope</em>. The typical usage looks like this:</p><pre>viewModelScope.launch {<br>    // ... implementation<br>}</pre><p>In Android development, coroutines are commonly launched from ViewModel classes using <em>viewModelScope</em>. The typical usage looks like this:</p><pre>viewModelScope.launch {<br>    // … implementation<br>}</pre><p>By default, if a dispatcher is not specified, any coroutine launched in <em>viewModelScope</em> will run on the <strong>main</strong> thread. However, in most use cases, we launch these coroutines to perform background tasks, such as — making API calls, or database operations. To ensure these tasks run in the background thread, it is essential to specify an appropriate dispatcher:</p><ul><li><em>I/O tasks</em> should use <strong>Dispatchers.IO</strong></li><li><em>CPU-intensive tasks</em> should use <strong>Dispatchers.Default</strong></li><li><em>UI updates</em> should use <strong>Dispatchers.Main</strong></li></ul><p>For example, to run an I/O task, we can specify the dispatcher like this:</p><pre>viewModelScope.launch(Dispatchers.IO) {<br>    // ...implementation<br>}</pre><h4>Optimizing Coroutine Launching</h4><p>To streamline coroutine launching, we can create extension functions on <em>ViewModel</em> that automatically use the specified dispatcher by default.</p><h4>Step 1: Create Extension Functions</h4><p>We can define extension functions for different dispatchers:</p><pre>kotlin<br>fun ViewModel.launchIO(block: suspend CoroutineScope.() -&gt; Unit) {<br>    viewModelScope.launch(Dispatchers.IO, block = block)<br>}<br><br>fun ViewModel.launchDefault(block: suspend CoroutineScope.() -&gt; Unit) {<br>    viewModelScope.launch(Dispatchers.Default, block = block)<br>}<br><br>fun ViewModel.launchMain(block: suspend CoroutineScope.() -&gt; Unit) {<br>    viewModelScope.launch(Dispatchers.Main, block = block)<br>}</pre><h4>Step 2: Use the Extension Functions</h4><p>You can now use these extension functions in your ViewModel as follows:</p><pre>class MyViewModel : ViewModel() {<br>    fun fetchData() {<br>        launchIO {<br>            // … implementation<br>        }<br>    }<br>}<br></pre><h4>Benefits</h4><ul><li><em>Consistency</em>: These extension functions maintain consistent coroutine usage for specific tasks.</li><li><em>Readability</em>: The function names clearly indicate their purpose, making the code easier to understand.</li><li><em>Maintainability</em>: Centralizing dispatcher management simplifies updates and modifications over time.</li></ul><h4>Optional: Single Extension Function with Overloading</h4><p>As an alternative, you can create a single extension function that accepts a dispatcher as a parameter. By default, this function can run on the I/O dispatcher:</p><pre>fun ViewModel.launchOn(dispatcher: CoroutineDispatcher = Dispatchers.IO, block: suspend CoroutineScope.() -&gt; Unit) {<br>    viewModelScope.launch(dispatcher, block = block)<br>}</pre><h4>Example Usage</h4><p>We can then use this overloaded function for different dispatchers:</p><pre>class MyViewModel : ViewModel() {<br><br>    fun someDatabaseOperation() {<br>        launchOn(Dispatchers.IO) {<br>            // … implementation<br>        }<br>    }<br><br>    fun someUiUpdates() {<br>        launchOn(Dispatchers.Main) {<br>            // … implementation<br>        }<br>    }<br><br>    fun someCPUIntensiveTask() {<br>        launchOn(Dispatchers.Default) {<br>            // … implementation<br>        }<br>    }<br>}</pre><h4>Conclusion</h4><p>Implementing a structured approach to launching coroutines in your ViewModel helps improve code quality, maintainability, and readability. By utilizing extension functions or a flexible overloaded function, you can ensure that your coroutines run on the appropriate dispatcher, aligning with best practices in Android development.</p><p>Thank you for reading. Please share feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b559094b828e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/coroutines-and-dispatchers-b559094b828e">Coroutines and Dispatchers</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Different Build Variants in Android]]></title>
            <link>https://medium.com/mindorks/creating-different-build-variants-in-android-8291b95352f5?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/8291b95352f5</guid>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Tue, 08 Dec 2020 12:57:57 GMT</pubDate>
            <atom:updated>2020-12-08T12:57:57.813Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://blog.mindorks.com/build-variants-in-android">Creating Different Build Variants in Android</a></li><li><a href="https://blog.mindorks.com/jetpack-compose-tutorial">Jetpack Compose Tutorial — Step by Step Guide</a></li><li><a href="https://blog.mindorks.com/jetpack-compose-navigation">Jetpack Compose: Navigation</a></li><li><a href="https://blog.mindorks.com/pagination-in-jetpack-compose">Pagination in Jetpack Compose</a></li><li><a href="https://blog.mindorks.com/exifinterface">Understanding ExifInterface</a></li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8291b95352f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/creating-different-build-variants-in-android-8291b95352f5">Creating Different Build Variants in Android</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Jetpack Compose for Android by Examples]]></title>
            <link>https://medium.com/mindorks/learn-jetpack-compose-for-android-by-examples-a1461f6388a?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/a1461f6388a</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[compose]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Mon, 02 Nov 2020 05:02:09 GMT</pubDate>
            <atom:updated>2020-11-02T05:47:58.468Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p>We just open-sourced a project to learn Jetpack Compose for Android by Examples.</p><p>Jetpack Compose is Android’s modern toolkit for building native UI.</p><p>Project Link: <a href="https://github.com/MindorksOpenSource/Jetpack-Compose-Android-Examples"><strong>Jetpack-Compose-Android-Examples</strong></a></p><p>You will be learning:</p><ul><li>How to build UI using Jetpack Compose in Android?</li><li>How to display a Text and apply various styles to a Text?</li><li>How to display a TextField(EditText) and apply various styles on it?</li><li>How to use the Preview and PreviewParameter feature offered by Android Studio?</li><li>Learn how to use various layouts such as Column, ScrollableColumn, LazyColumn, Row, ScrollableRow, Box, Stack, and ConstraintLayout in Jetpack Compose?</li><li>Learn the usage of Clickable in Jetpack Compose with the help of examples.</li><li>How to use Buttons, Card, Images, AlertDialog in Jetpack Compose?</li><li>Through the Jetpack Compose tutorial, you will learn various Material Design UI elements such as BottomAppBar, TopAppBar, BottomNavigation, Checkbox, CircularProgressIndicator, LinearProgressIndicator, RadioButton, Slider, Snackbar, and Switch.</li><li>Learn how to make Custom Views in Jetpack Compose?</li><li>How to add animation such as Crossfade and Shape Rotation in Jetpack Compose?</li></ul><p>Project Link: <a href="https://github.com/MindorksOpenSource/Jetpack-Compose-Android-Examples"><strong>Jetpack-Compose-Android-Examples</strong></a></p><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1461f6388a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/learn-jetpack-compose-for-android-by-examples-a1461f6388a">Learn Jetpack Compose for Android by Examples</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate to Gradle Kotlin DSL]]></title>
            <link>https://medium.com/mindorks/migrate-to-gradle-kotlin-dsl-7eec7babbb2d?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/7eec7babbb2d</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Tue, 27 Oct 2020 05:49:29 GMT</pubDate>
            <atom:updated>2020-10-27T05:49:29.054Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://blog.mindorks.com/migrate-to-gradle-kotlin-dsl">Migrate to Gradle Kotlin DSL</a></li><li><a href="https://www.youtube.com/watch?v=bTIEypbIxlE">Android Architecture Components</a></li><li><a href="https://www.youtube.com/watch?v=5bVP_J4-cbg">Retrofit with Kotlin Coroutines in Android - Tutorial</a></li><li><a href="https://www.youtube.com/watch?v=5HKogXsjwi8">Jetpack DataStore Preferences - Tutorial</a></li><li><a href="https://blog.mindorks.com/in-app-review">In-App Review in Android</a></li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7eec7babbb2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/migrate-to-gradle-kotlin-dsl-7eec7babbb2d">Migrate to Gradle Kotlin DSL</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Text Styling with Spans]]></title>
            <link>https://medium.com/mindorks/android-text-styling-with-spans-f27671b6a4c?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/f27671b6a4c</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Tue, 29 Sep 2020 13:43:55 GMT</pubDate>
            <atom:updated>2020-09-29T13:43:54.954Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://blog.mindorks.com/spannable-string-text-styling-with-spans">Spannable String: Text Styling with Spans</a></li><li><a href="https://blog.mindorks.com/how-does-the-kotlin-multiplatform-work">How does the Kotlin Multiplatform work?</a></li><li><a href="https://blog.mindorks.com/custom-snackbar">Custom Snackbar in Android</a></li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f27671b6a4c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/android-text-styling-with-spans-f27671b6a4c">Android Text Styling with Spans</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Android Developer Interview]]></title>
            <link>https://medium.com/mindorks/google-android-developer-interview-640b0a35559c?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/640b0a35559c</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[interview-questions]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 04:56:03 GMT</pubDate>
            <atom:updated>2022-11-25T09:27:42.766Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://amitshekhar.me/blog/google-android-developer-interview">Google Android Developer Interview</a></li><li>Interview Question: Smallest Multiple With 0 and 1</li><li>Sort List — Merge Sort</li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=640b0a35559c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/google-android-developer-interview-640b0a35559c">Google Android Developer Interview</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RecyclerView Optimization]]></title>
            <link>https://medium.com/mindorks/recyclerview-optimization-b51912acabaf?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/b51912acabaf</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 13:02:50 GMT</pubDate>
            <atom:updated>2022-11-25T09:33:43.088Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://amitshekhar.me/blog/recyclerview-optimization">RecyclerView Optimization — Scrolling Performance Improvement</a></li><li><a href="https://amitshekhar.me/blog/android-app-lag">Performance Tips — Smooth Running Android App</a></li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b51912acabaf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/recyclerview-optimization-b51912acabaf">RecyclerView Optimization</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete Kotlin Tutorial For Android Developers]]></title>
            <link>https://medium.com/mindorks/complete-kotlin-tutorial-for-android-developers-a68c31f70ec5?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/a68c31f70ec5</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Mon, 17 Aug 2020 13:54:15 GMT</pubDate>
            <atom:updated>2020-08-17T13:54:15.776Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://www.youtube.com/playlist?list=PL6nth5sRD25iv8jZrQWD-5dXgu56ae5m8">Learn Kotlin — Kotlin Tutorial For Beginners</a></li><li><a href="https://blog.mindorks.com/how-to-reduce-apk-size-in-android-2f3713d2d662">How to reduce APK size in Android?</a></li><li><a href="https://blog.mindorks.com/desugaring-in-android">Desugaring in Android</a></li><li><a href="https://blog.mindorks.com/paging-3-tutorial">Paging 3 Android Tutorial</a></li><li><a href="https://android-developers.googleblog.com/2020/08/in-app-review-api.html">Leverage the In-App Review API for your Google Play reviews</a></li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a68c31f70ec5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/complete-kotlin-tutorial-for-android-developers-a68c31f70ec5">Complete Kotlin Tutorial For Android Developers</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin filtering function — partition]]></title>
            <link>https://medium.com/mindorks/kotlin-filtering-function-partition-764d61895415?source=rss----f1a763fc7443--android</link>
            <guid isPermaLink="false">https://medium.com/p/764d61895415</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Amit Shekhar]]></dc:creator>
            <pubDate>Wed, 29 Jul 2020 03:34:46 GMT</pubDate>
            <atom:updated>2020-07-29T03:34:46.538Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p><strong>Here is the list of good content for you.</strong></p><ol><li><a href="https://twitter.com/MindOrksNextGen/status/1286164964525441025">Kotlin filtering function — partition()</a></li><li><a href="https://blog.mindorks.com/kotlin-flow-retry-operator-with-exponential-backoff-delay">Kotlin Flow Retry Operator with Exponential Backoff Delay</a></li><li><a href="https://twitter.com/MindOrksNextGen/status/1282527377952776193">Android App Release Checklist For The Production Launch</a></li><li><a href="https://blog.mindorks.com/shared-viewmodel-in-android-shared-between-fragments">Shared ViewModel in Android</a></li><li><a href="https://blog.mindorks.com/understanding-multidex-in-android">Understanding Multidex in Android</a></li></ol><p>Thanks</p><p><strong>Team MindOrks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=764d61895415" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mindorks/kotlin-filtering-function-partition-764d61895415">Kotlin filtering function — partition</a> was originally published in <a href="https://medium.com/mindorks">MindOrks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>