<?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 shalen mathew on Medium]]></title>
        <description><![CDATA[Stories by shalen mathew on Medium]]></description>
        <link>https://medium.com/@shalenmathew?source=rss-5cc1f660ff31------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sm86Zdo00RXxgZtfMYGkJw.png</url>
            <title>Stories by shalen mathew on Medium</title>
            <link>https://medium.com/@shalenmathew?source=rss-5cc1f660ff31------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:00:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shalenmathew/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[Android CI/CD for Beginners — #4: Automating Unit Tests with GitHub Actions]]></title>
            <link>https://blog.watermelonkode.com/android-ci-cd-for-beginners-4-automating-unit-tests-with-github-actions-4d2dddaf392d?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d2dddaf392d</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 08:10:51 GMT</pubDate>
            <atom:updated>2026-10-30T14:18:02.346Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to run Android unit tests with Gradle and automate test execution in GitHub Actions to catch bugs and regressions before changes are merged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WGcw90O8jF7tcr8Kqw-NA.png" /></figure><h3>What Is a Unit Test?</h3><p>A unit test verifies a small, isolated piece of code to ensure it behaves as expected.</p><p>We’ll assume you’re already familiar with the basics of unit testing, so we won’t dive deep into the concepts in this article. Instead, we’ll focus on running Android unit tests with Gradle and automating them using GitHub Actions.</p><p>(<em>Disclaimer: If you’re unfamiliar with unit testing, I recommend learning the basics before proceeding.</em>)</p><h3>Why Do We Need Unit Tests?</h3><p>As an open-source developer working on projects like <a href="https://github.com/shalenMathew/MovieFlix_App"><strong>MovieFlix</strong></a> and <a href="https://github.com/shalenMathew/Quotes-app"><strong>Quotes App</strong></a>, I receive contributions from developers around the world.</p><p>With different people making changes to the codebase, I need to ensure that the core business logic continues to work as expected, even as new features and changes are introduced.</p><p>That’s where unit tests help. They allow me to verify that existing logic still behaves correctly after code changes, reducing the risk of accidentally breaking something that was already working.</p><p>The same applies to large organizations, where multiple developers and teams work on the same codebase.</p><p>With frequent changes happening across different parts of an application, unit tests help ensure that existing functionality remains stable while the application evolves.</p><p>Instead of manually running unit tests every time code changes, we can automate them using CI.</p><p>For example, we can configure GitHub Actions to run unit tests automatically whenever a pull request is opened or updated, helping us catch regressions before changes are merged into the main codebase.</p><h3>Running Unit Tests Locally</h3><p>Before automating unit tests in CI, let’s first understand how to run them locally using Gradle.</p><p>Android projects using Gradle can run unit tests through the Gradle wrapper. From your project’s root directory, execute:</p><pre>./gradlew test</pre><p>This runs the applicable unit test tasks configured across your project.</p><p>If you want to run only the debug unit tests for the app module, you can use:</p><pre>./gradlew :app:testDebugUnitTest</pre><p>Once the tests finish, Gradle generates a test report that you can open in your browser to inspect the results.</p><p>Running tests locally helps us verify our changes during development. However, we don’t want to rely on every contributor remembering to run them before submitting code. That’s why we’ll automate this process in GitHub Actions in the next section.</p><h3>Integrating Unit Tests into GitHub Actions</h3><p>Now that we know how to run unit tests locally, let’s automate them using GitHub Actions.</p><p>As discussed earlier, we want unit tests to run automatically when a pull request is opened or updated. This allows us to validate code changes without relying on contributors to run the tests manually.</p><p>We’ll add a unit-test job to our existing workflow:</p><pre>unit-test:<br>  name: Unit Test<br>  needs: [lint]<br>  runs-on: ubuntu-latest<br><br>  steps:<br>    - name: Checkout repository<br>      uses: actions/checkout@v4<br><br>    - name: Grant Gradle wrapper execute permission<br>      run: chmod +x ./gradlew<br><br>    - name: Setup Gradle cache<br>      uses: actions/cache@v4<br>      with:<br>        path: |<br>          ~/.gradle/caches<br>          ~/.gradle/wrapper<br>        key: ${{ runner.os }}-gradle-${{ hashFiles(&#39;**/*.gradle*&#39;, &#39;**/gradle-wrapper.properties&#39;) }}<br>        restore-keys: |<br>          ${{ runner.os }}-gradle-<br><br>    - name: Run tests<br>      run: ./gradlew test<br><br>    - name: Upload the test report<br>      if: always()<br>      uses: actions/upload-artifact@v4<br>      with:<br>        name: unit-test-report<br>        path: app/build/reports/tests/testDebugUnitTest/</pre><p>Let’s look at a few important parts of this job.</p><ul><li><strong>needs: [lint]</strong> — Ensures the unit-test job runs only after the lint job succeeds. If Lint fails, this job is skipped by default. <em>(If you&#39;re wondering why I’m talking about lint, follow the earlier parts of this series for better context.)</em></li><li><strong>./gradlew test</strong> — Runs the applicable unit test tasks configured in the project.</li><li><strong>if: always()</strong> — Attempts to upload the test report even if an earlier step fails, provided a report was generated.</li></ul><p>The remaining steps, including checking out the repository, setting Gradle wrapper permissions, and caching Gradle files, follow the same approach we used in the previous part.</p><p>With this addition, unit tests become another automated check in our CI pipeline. If a test fails, the job fails, allowing us to investigate the issue before merging the pull request.</p><p><strong>Note:</strong> The report path targets the app module&#39;s debug unit-test report. Because the job depends on Lint, tests won&#39;t run if Lint fails. This is a deliberate pipeline choice, but it means unit tests won&#39;t independently report their results on those runs.</p><h3>Viewing Test Results</h3><p>Once the workflow finishes, we can access the unit test report directly from GitHub Actions.</p><p>To view it:</p><ol><li>Open your repository on GitHub and navigate to the <strong>Actions</strong> tab.</li><li>Select the workflow run you want to inspect.</li><li>Find the unit-test-report artifact in the run summary and download it.</li><li>Extract the downloaded archive and open index.html in your browser.</li></ol><p>The report provides an overview of the executed tests, including passed and failed tests, along with details to help investigate failures.</p><p>Take some time to explore the report and its contents. Understanding these results will help you identify issues when your automated tests run in CI.</p><h3>Conclusion</h3><p>We’ve automated Android unit tests using GitHub Actions to catch regressions before changes are merged.</p><p>In the next part, we’ll explore <strong>Android Instrumentation Testing</strong> and how to automate it in CI.</p><p>Bye for now ✌️💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d2dddaf392d" width="1" height="1" alt=""><hr><p><a href="https://blog.watermelonkode.com/android-ci-cd-for-beginners-4-automating-unit-tests-with-github-actions-4d2dddaf392d">Android CI/CD for Beginners — #4: Automating Unit Tests with GitHub Actions</a> was originally published in <a href="https://blog.watermelonkode.com/">Kotlin Multiplatform Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android CI/CD for Beginners — #3: Automating Android Code Quality]]></title>
            <link>https://blog.watermelonkode.com/android-ci-cd-for-beginners-3-automating-android-code-quality-6365fa4fa40f?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/6365fa4fa40f</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 15:17:08 GMT</pubDate>
            <atom:updated>2026-10-28T15:17:08.760Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to automate code quality checks in Android using Android Lint and GitHub Actions, and catch potential issues before they make it into your codebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9WYgSHYtyYsmieT-MtRHdg.png" /></figure><h3>Introduction</h3><p>In <a href="#">Part 1</a>, we explored the fundamentals of CI/CD, why automation matters in Android development, and how it helps teams maintain a reliable codebase.</p><p>In <a href="#">Part 2</a>, we created our first GitHub Actions workflow and learned how to automate tasks in response to events in a GitHub repository.</p><p>Now, it’s time to put that knowledge to practical use in an Android project.</p><p>In real-world projects, multiple developers contribute code, introduce new features, and fix bugs. With every change, there’s a possibility of introducing issues or affecting existing functionality.</p><p>That’s why it’s important to identify potential problems as early as possible, ideally before changes are merged into the main codebase.</p><p>One way to do this is through <strong>automated code quality checks</strong>.</p><p>In this part, we’ll explore <strong>Android Lint</strong> and integrate it into our GitHub Actions workflow to automatically analyze our Android project. We’ll also learn how to access the generated Lint report and understand how these checks help us catch potential issues during development.</p><h3>ok, But why do we even need this?</h3><p>Recently, a contributor submitted a pull request to my Android project, <a href="https://github.com/shalenMathew/MovieFlix_App"><strong>MovieFlix</strong></a>. The GitHub Actions workflow ran automatically, but the <strong>Lint Checks job failed</strong>.</p><p>Without CI, I would have had to pull the changes locally, wait for Gradle to build the project, only to discover that something had failed. Instead, GitHub Actions caught the issue automatically, without me having to do anything.</p><p>That’s the real benefit of CI: <strong>catching potential issues early while saving time and manual effort.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3T8b-qGAOVey9fywiIxTCA.png" /></figure><h3>What Is Android Lint?</h3><p>Android Lint is a static analysis tool that helps identify potential problems in your Android project without needing to run the app.</p><p>It analyzes your source code, resources, and project configuration to detect issues such as:</p><ul><li><strong>Potential bugs:</strong> Code patterns that could lead to unexpected behavior.</li><li><strong>Unused resources:</strong> Unused strings, layouts, drawables, and other resources that can be removed.</li><li><strong>Accessibility issues:</strong> Problems that may make your app harder for users with disabilities to use.</li><li><strong>Performance issues:</strong> Code or resource usage that could negatively affect app performance.</li><li><strong>Best practices:</strong> Code and configuration that could be improved to follow Android development guidelines.</li></ul><p>You can run Android Lint locally using Gradle in your terminal:</p><pre>./gradlew lintDebug</pre><p>This command runs Lint checks for your project’s debug build variant and generates a report containing the findings.</p><p>Running Lint locally is useful, but it depends on developers remembering to run the checks. By integrating it into GitHub Actions, we can automate the process and identify potential issues whenever changes trigger our workflow, before those changes are merged into the main codebase.</p><h3>Integrating Android Lint into GitHub Actions</h3><p>Now that we understand what Android Lint does, let’s integrate it into our GitHub Actions workflow.</p><p>We’ll start with a simple implementation that runs Lint in CI. Then, we’ll improve it by adding Gradle caching and uploading the generated report.</p><h4>1. Running Lint in GitHub Actions</h4><p>Let’s begin with a basic lint job:</p><pre>lint:<br>  name: Lint Checks<br>  runs-on: ubuntu-latest<br><br>steps:<br>    - name: Checkout repository<br>      uses: actions/checkout@v4<br><br>    - name: Run Android Lint<br>      run: ./gradlew lintDebug</pre><p>This job contains two steps:</p><ul><li><strong>Checkout repository:</strong> The actions/checkout action checks out our repository code onto the runner so that the workflow can access our project files.</li><li><strong>Run Android Lint:</strong> The Gradle command runs Lint checks for the debug build variant of our Android project.</li></ul><p>With this basic setup, we can run Android Lint automatically whenever the workflow is triggered.</p><p>However, we can make this workflow more practical by addressing a few things: ensuring the Gradle wrapper can execute, reducing unnecessary dependency downloads, and making the Lint report accessible after the workflow finishes.</p><h4>2. Optimizing the Workflow</h4><p>Let’s look at three improvements that can make our CI workflow more convenient and efficient.</p><h4>Granting Execute Permission to Gradle</h4><p>Our workflow runs on an Ubuntu machine, where the Gradle wrapper must have execute permission to run as ./gradlew.</p><p>If the executable permission isn’t already present, the command will fail with a permission error. We can avoid this by adding the following step before running Lint:</p><pre>- name: Grant Gradle wrapper execute permission<br>  run: chmod +x ./gradlew</pre><p>This ensures the wrapper can be executed. If the executable permission is already preserved in the repository, this step may not be necessary.</p><h4>Caching Gradle Files</h4><p>Gradle downloads dependencies and stores files in its local cache. Without caching between workflow runs, the runner may need to download dependencies again, increasing execution time.</p><p>We can use GitHub Actions’ cache action to reuse Gradle files across runs:</p><pre>- name: Cache Gradle files<br>  uses: actions/cache@v4<br>  with:<br>    path: |<br>      ~/.gradle/caches<br>      ~/.gradle/wrapper<br>    key: ${{ runner.os }}-gradle-${{ hashFiles(&#39;**/*.gradle*&#39;, &#39;**/gradle-wrapper.properties&#39;) }}<br>    restore-keys: |<br>      ${{ runner.os }}-gradle-</pre><p>Here’s what the important settings mean:</p><ul><li>path specifies which Gradle directories should be cached.</li><li>key creates a cache identifier based on the operating system and the contents of the matching Gradle configuration files.</li><li>restore-keys provides a fallback prefix that GitHub Actions can use to find a compatible cache when an exact match isn&#39;t available.</li></ul><p>When the configuration files change, the cache key may change as well. Gradle can then use a different cache while still benefiting from a compatible fallback cache when available.</p><p>Caching is optional, but it can reduce setup time on subsequent runs. It doesn’t eliminate the need for Gradle to resolve dependencies or perform the requested task.</p><h4>Uploading the Lint Report</h4><p>Running Lint is useful, but we also need a convenient way to inspect its findings after the workflow runs.</p><p>By default, Gradle generates a report in the project’s build directory. We can upload the HTML report as a GitHub Actions artifact:</p><pre>- name: Upload Lint report<br>  if: always()<br>  uses: actions/upload-artifact@v4<br>  with:<br>    name: lint-report<br>    path: app/build/reports/lint-results-debug.html<br>    if-no-files-found: warn</pre><p>The actions/upload-artifact action makes the report available to download from the workflow run.</p><p>A couple of settings are worth noting:</p><ul><li>if: always() tells GitHub Actions to attempt the upload even if an earlier step fails.</li><li>if-no-files-found: warn produces a warning if the report doesn&#39;t exist, rather than failing the upload step because the file is missing.</li></ul><p>This is particularly useful when Lint fails and we want to check whether a report was generated.</p><h4>3. Putting It All Together</h4><p>Now let’s combine these improvements into our complete lint job:</p><pre>name: 🚨 Main WorkFlow<br><br>on:<br>  pull_request:<br>    branches: [ &quot;master&quot;,  &quot;development&quot;]<br><br>  workflow_dispatch:<br><br><br><br>concurrency:<br>  group: blank-${{ github.ref }}<br>  cancel-in-progress: true<br><br><br>jobs:<br><br>  lint:<br>    name: Lint Checks<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - uses: actions/checkout@v4<br><br>      - name: Give gradlew execute permission<br>        run: chmod +x ./gradlew<br><br>      - name: Setup Gradle cache<br>        uses: actions/cache@v4<br>        with:<br>          path: |<br>            ~/.gradle/caches<br>            ~/.gradle/wrapper<br>          key: ${{ runner.os }}-gradle-${{ hashFiles(&#39;**/*.gradle*&#39;, &#39;**/gradle-wrapper.properties&#39;, &#39;gradle/libs.versions.toml&#39;, &#39;buildSrc/**&#39;, &#39;build-logic/**&#39;) }}<br>          restore-keys: |<br>            ${{ runner.os }}-gradle-<br><br><br>      - name: Run lint<br>        run: ./gradlew lintDebug<br><br>      - name: Upload lint report<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: lint-report<br>          path: app/build/reports/lint-results-debug.html</pre><p>This job now runs Lint, uses caching to help reduce repeated setup work, and attempts to upload the generated report.</p><h3>Viewing the Lint Report</h3><p>Try to manually trigger the workflow for learning , once the workflow finishes, you can access the generated Lint report from GitHub Actions.</p><p><strong>So how to trigger a manual workflow ?<br></strong>After pushing your workflow code , go to your repo and you will find a tab named Actions , there on left side you , below <strong><em>Workflows</em></strong> section you will find the name of all workflow in your current repo</p><p>Just click on your workflow, the on right side on top you will find a huge button named<strong> <em>Run Workflow</em>, </strong>click it and you will manually trigger your workflow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03IIknHzaohD103PBF-HVg.png" /></figure><p>Now all you got to do is wait , once the checks are complete you will find your lint report, you can download the report and take a look into it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXG1xAuT16wVS2CUKbOPRg.png" /></figure><p>The report contains details about the issues detected by Android Lint, helping you identify potential problems in your project.</p><p>Take some time to explore the report and understand its findings. As you work on Android projects, you’ll become more familiar with the different types of issues Lint can detect.</p><h3>Conclusion</h3><p>In this part, we integrated Android Lint into GitHub Actions and improved our workflow with Gradle caching and automated report uploads.</p><p>With these checks running automatically, we can catch potential code quality issues earlier and make the review process smoother.</p><p>In the next part, we’ll take things a step further by <strong>automating unit tests in GitHub Actions</strong>, so we can verify our code’s behavior and catch regressions before changes are merged.</p><p>Stay tuned! ✌️💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6365fa4fa40f" width="1" height="1" alt=""><hr><p><a href="https://blog.watermelonkode.com/android-ci-cd-for-beginners-3-automating-android-code-quality-6365fa4fa40f">Android CI/CD for Beginners — #3: Automating Android Code Quality</a> was originally published in <a href="https://blog.watermelonkode.com/">Kotlin Multiplatform Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android CI/CD for Beginners — #2: GitHub Actions Fundamentals]]></title>
            <link>https://blog.watermelonkode.com/android-ci-cd-for-beginners-part-2-github-actions-fundamentals-bff8d2796dcd?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/bff8d2796dcd</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 13:17:20 GMT</pubDate>
            <atom:updated>2026-10-27T21:23:30.940Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android CI/CD for Beginners — #2: GitHub Actions Fundamentals</h3><p>We will learn Github Actions fundamentals &amp; create our first workflow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bz_IFGB7ruCS0i1bridPA.png" /></figure><p>In Part 1, we covered what CI/CD is, why automation is useful in Android development, and the terminology behind CI/CD. Now it’s time to put those concepts into practice.</p><p>In this part, we’ll introduce GitHub Actions and create a simple workflow from scratch. We won’t build or test an Android app yet — the goal is to understand how a GitHub Actions workflow works.</p><h3>What is GitHub Actions?</h3><p>GitHub Actions is GitHub’s automation and CI/CD platform. It allows you to automatically <strong>run tasks in response to events</strong> in your repository, such as <strong>pushing code or opening a pull request</strong>.</p><p>In simple terms, GitHub Actions allows you to <strong>automatically run specific tasks based on events in your repository</strong>. Some of the most common triggers are <strong>pushing code</strong> or <strong>opening or updating a pull request</strong>.</p><h3>Where do GitHub Actions workflows live?</h3><p>GitHub Actions workflows are stored as <strong>YAML files</strong> inside the .github/workflows/ directory of your repository.</p><p>To create a workflow, create a .github/workflows/ folder in the root of your project, and then add a file with a .yml or .yaml extension. This file will contain the configuration for your GitHub Actions workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*c_3-1ENXneCHxLlRLGQxAg.png" /></figure><h3>Anatomy of a GitHub Actions Workflow</h3><p>A GitHub Actions workflow is defined using a YAML file. It tells GitHub <strong>when the workflow should run, what work needs to be performed, and where that work should be executed</strong>.</p><p>At a high level, a workflow consists of three main parts:</p><ul><li><strong>Trigger (</strong><strong>on)</strong> — Defines when the workflow should run.</li><li><strong>Jobs (</strong><strong>jobs)</strong> — Defines the tasks that need to be performed.</li><li><strong>Steps (</strong><strong>steps)</strong> — Defines the individual commands or actions that make up a job.</li></ul><p><em>Lets create our firts workflow for more clarity:</em></p><p><em>You can write this below code in your .yml file</em></p><pre>name: My First Workflow<br><br>on:<br>  push:<br><br>jobs:<br><br>  hello:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Say Hello<br>        run: echo &quot;Hello from GitHub Actions!&quot;</pre><p>Let’s break this down.</p><p><strong>1</strong>. name</p><pre>name: My First Workflow</pre><p>The name gives your workflow a readable name. This is the name you&#39;ll see in the <strong>Actions</strong> tab of your GitHub repository.</p><p><strong>2.</strong> on</p><pre>on:<br>  push:</pre><p>The on section defines the <strong>event that triggers the workflow</strong>.</p><p>In this example, the workflow runs whenever code is pushed to the repository.</p><p>Other common events include:</p><pre>on:<br>  pull_request:</pre><p>which runs the workflow when a pull request is opened or updated.</p><p><strong>3.</strong> jobs</p><pre>jobs:</pre><p>The jobs section defines the actual work that the workflow needs to perform.</p><p>A workflow can contain one or multiple jobs. Jobs can run independently, in parallel, or depend on the completion of other jobs.</p><p><strong>4.</strong> job id</p><pre>hello:</pre><p>hello is the unique identifier for this job. You can choose a descriptive name such as build, test, or lint.</p><p><strong>5.</strong> runs-on</p><pre>runs-on: ubuntu-latest</pre><p>This is where the job will actually <strong>run</strong>.</p><p>When you run an Android project locally, your commands execute on your own computer. With GitHub Actions, the commands need a machine to execute them on. GitHub provides <strong>runners</strong>, which are virtual machines hosted by GitHub specifically for running your workflows.</p><p>In this example:</p><pre>runs-on: ubuntu-latest</pre><p>we’re telling GitHub Actions:</p><blockquote><strong><em>Run this job on a GitHub-hosted machine running Ubuntu.</em></strong></blockquote><p>So when the workflow starts, GitHub provides an Ubuntu environment, and the steps in our job are executed on that machine.</p><p>You don’t need to manage or maintain this server yourself. GitHub takes care of creating the runner and providing the operating system and environment needed to execute your workflow.</p><p>For example, when we eventually run:</p><pre>./gradlew assembleDebug</pre><p>that command won’t run on your laptop. It will run <strong>inside the GitHub Actions runner</strong>.</p><p>Understanding this is important because CI/CD is essentially running your development tasks on remote machines automatically. Later in this series, we’ll configure that environment with Java, the Android SDK, Gradle, and other tools required to build and test an Android application.</p><p><strong>6.</strong> steps</p><pre>steps:</pre><p>A job is made up of one or more <strong>steps</strong>. Each step performs an individual task.</p><p>For example:</p><pre>steps:<br>  - name: Say Hello<br>    run: echo &quot;Hello from GitHub Actions!&quot;</pre><p>Here, the step executes a shell command using run.</p><p>The command:</p><pre>echo &quot;Hello from GitHub Actions!&quot;</pre><p>is nothing but printing a sentence , we are executing this line on Ubuntu runner, not on your local machine.</p><p>As we progress through the series, these simple steps will become actual Android development tasks, such as setting up Java, building the project with Gradle, running Lint, and executing tests</p><p>For now, the important thing to remember is:</p><pre>Workflow<br>   │<br>   ├── Trigger (`on`)<br>   │<br>   └── Jobs<br>        │<br>        └── Job<br>             │<br>             ├── Runner (`runs-on`)<br>             │<br>             └── Steps<br>                  ├── Step<br>                  ├── Step<br>                  └── Step</pre><p>This basic structure is the foundation of every GitHub Actions workflow we’ll build throughout this series.</p><h3>Push the Workflow to GitHub</h3><p>So we have created our firts workflow now lets run it.<br>Once you’ve created the workflow file, commit it to your repository and push it to GitHub.</p><p>As soon as the code is pushed, the push event defined in our workflow is triggered:</p><pre>on:<br>  push:</pre><p>GitHub Actions will detect this event and automatically start the workflow.</p><p>You can then open your repository on GitHub and navigate to the <strong>Actions</strong> tab to see the workflow run.</p><p>If everything worked fine you will able to see the printed statement in you Github actions tab , cause that what we told our job to do</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUftLs5Llqpx3B4P8PzODw.png" /></figure><p>You can checkout my production ready app <a href="https://github.com/shalenMathew/Quotes-app"><em>Quotes app</em></a><em> </em>where i have written much more complex workflows</p><h3>What’s Next?</h3><p>We’ve now created and executed our first GitHub Actions workflow.</p><p>Although our workflow only prints a simple message, we’ve already gone through the core process:</p><pre>Push Code<br>    ↓<br>Trigger Workflow<br>    ↓<br>Start Runner<br>    ↓<br>Run Job<br>    ↓<br>Execute Steps<br>    ↓<br>Workflow Result</pre><p>These are the same building blocks we’ll use to create a real Android CI/CD pipeline.</p><h3>In Part 3</h3><p>We’ll start adding real Android CI checks to our workflow, with a focus on <strong>code quality and linting</strong>.</p><p>We’ll cover:</p><ul><li>Setting up the Android project in the CI environment</li><li>Running <strong>Android Lint</strong> automatically</li><li>Understanding what happens when Lint finds issues</li><li>Making the workflow fail when quality checks don’t pass</li><li>Running these checks automatically on pull requests</li></ul><p>This will be our first step toward turning a simple GitHub Actions workflow into a practical <strong>Android CI pipeline</strong>.</p><p>BYEEEE ✌️👋👋👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bff8d2796dcd" width="1" height="1" alt=""><hr><p><a href="https://blog.watermelonkode.com/android-ci-cd-for-beginners-part-2-github-actions-fundamentals-bff8d2796dcd">Android CI/CD for Beginners — #2: GitHub Actions Fundamentals</a> was originally published in <a href="https://blog.watermelonkode.com/">Kotlin Multiplatform Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android CI/CD for Beginners — #1: Introduction]]></title>
            <link>https://blog.watermelonkode.com/android-ci-cd-for-beginners-part-1-introduction-91c6e54f0e56?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/91c6e54f0e56</guid>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin-flow]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[android-developers]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Sun, 05 Jul 2026 15:31:18 GMT</pubDate>
            <atom:updated>2026-10-27T19:58:47.904Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android CI/CD for Beginners — #1: Introduction</h3><p>Stop building everything manually. Learn how modern Android teams automate their development workflow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6F7zz5GQE9uznjeXCojvw.png" /></figure><p>This series is designed to provide <em>a complete understanding of CI/CD for Android development</em>. In Part 1, we’ll introduce the fundamentals of CI/CD, explore what it is, why it matters, and how it’s used in Android app development.</p><p><strong>CI/CD (Continuous Integration and Continuous Delivery/Deployment)</strong> is a set of practices that automate repetitive tasks in the software development process, such as building, testing, and releasing applications.</p><p>Instead of manually performing these tasks every time you make a change, a CI/CD pipeline executes them automatically whenever predefined events occur, such as pushing code to a Git repository.</p><h3>How can CI/CD automate tasks in Android development?</h3><p>CI/CD automates many of the repetitive tasks involved in the Android development lifecycle. Instead of running these steps manually every time you make a change, they can be executed automatically whenever code is pushed to your repository.</p><p>With a CI/CD pipeline, your Android app can be automatically:</p><ul><li>Built using Gradle.</li><li>Analyzed for code quality with Android Lint.</li><li>Tested by running unit and instrumentation tests.</li><li>Packaged into a signed or unsigned APK or Android App Bundle (AAB).</li><li>Distributed to testers or prepared for release to the Google Play Store.</li></ul><p>You might be wondering: <strong>Why do we need to automate these tasks?</strong></p><p>In real-world Android projects, multiple developers often work on the same codebase. Every new feature, bug fix, or improvement is usually submitted as a pull request (PR).</p><p>Before those changes are merged, the team needs to ensure they meet the project’s quality standards and don’t introduce bugs or break existing functionality.</p><p>Manually building the app, running lint checks, executing tests, and verifying every pull request can quickly become repetitive and time-consuming, especially as the project grows.</p><p>This is where CI/CD becomes valuable. Whenever a pull request is opened or updated, a CI pipeline can automatically build the app, run lint checks, execute unit and instrumentation tests, and report whether all checks have passed.</p><p>If any step fails, developers are notified immediately, allowing issues to be fixed before the changes are merged.</p><p>Once all the automated checks succeed, the CD pipeline can take over by generating an APK or App Bundle and distributing it to testers or preparing it for release.</p><p>This eliminates many manual steps, speeds up the development process, and helps maintain a stable and reliable codebase.</p><h3>Common CI/CD Terminology</h3><p>Before we start building our first CI/CD pipeline, it’s important to understand some common terms you’ll encounter throughout this series. These concepts are not exclusive to Android development, they’re used across many CI/CD platforms. We’ll explore how these ideas come together in practice in the upcoming sections.</p><h3>Pipeline</h3><p>A <strong>pipeline</strong> is the complete automated process that runs after a specific event, such as pushing code to a Git repository or opening a pull request. A pipeline can build your app, run tests, generate an APK, and even distribute it to testers — all without manual intervention.</p><p>Think of a pipeline as a sequence of automated tasks executed in a predefined order.</p><h3>Workflow</h3><p>In GitHub Actions, a pipeline is defined using a <strong>workflow</strong>. A workflow is a YAML (.yml or .yaml) file stored inside the .github/workflows directory of your project.</p><p>It describes <strong>what should happen</strong>, <strong>when it should happen</strong>, and <strong>how it should be executed</strong>.</p><p>A repository can contain multiple workflows, each responsible for different tasks. For example, one workflow may run tests for every pull request, while another creates a release build whenever a new version is published.</p><h3>Event (Trigger)</h3><p>A workflow doesn’t run on its own — it needs an <strong>event</strong>, also known as a <strong>trigger</strong>.</p><p>Common triggers include:</p><ul><li>Pushing code to a branch (push)</li><li>Opening or updating a pull request (pull_request)</li><li>Manually starting a workflow (workflow_dispatch)</li><li>Creating a release (release)</li></ul><p>Whenever one of these events occurs, GitHub Actions starts the corresponding workflow.</p><h3>Runner</h3><p>A <strong>runner</strong> is the machine responsible for executing your workflow.</p><p>GitHub provides hosted runners running Linux, Windows, and macOS. For Android projects, Linux runners are commonly used because they provide a fast and cost-effective environment for building Android applications.</p><p>You can also configure your own self-hosted runner if you need custom hardware or software.</p><h3>Job</h3><p>A <strong>job</strong> is a collection of related tasks executed on the same runner.</p><p>For example, one job might build the Android app, while another runs unit tests. Multiple jobs can run sequentially or in parallel, depending on how the workflow is configured.</p><h3>Step</h3><p>A <strong>step</strong> is a single task inside a job.</p><p>Examples of steps include:</p><ul><li>Checking out the repository</li><li>Setting up Java</li><li>Installing Android dependencies</li><li>Running Gradle commands</li><li>Uploading the generated APK</li></ul><p>A job is simply a sequence of steps executed one after another.</p><h3>Action</h3><p>An <strong>Action</strong> is a reusable piece of automation that performs a specific task.</p><p>Instead of writing everything from scratch, you can use actions created by GitHub or the community.</p><p>For example:</p><ul><li>actions/checkout downloads your repository onto the runner.</li><li>actions/setup-java installs and configures Java.</li><li>actions/upload-artifact uploads build outputs such as APKs or test reports.</li></ul><p>Actions make workflows shorter, cleaner, and easier to maintain.</p><h3>Artifact</h3><p>An <strong>artifact</strong> is a file generated during a workflow that you want to keep after the workflow finishes.</p><p>In Android projects, common artifacts include:</p><ul><li>APK files</li><li>Android App Bundles (AAB)</li><li>Lint reports</li><li>Unit test reports</li><li>Code coverage reports</li></ul><p>Artifacts can be downloaded later for testing, debugging, or distribution.</p><h3>GitHub Actions</h3><p>Throughout this series, we’ll use <strong>GitHub Actions</strong> as our CI/CD platform.</p><p>GitHub Actions is GitHub’s built-in automation service that allows you to create workflows using YAML files. It automatically responds to events in your repository, runs your workflows on runners, and reports the results all directly within GitHub.</p><p>Now that you’re familiar with these core concepts, we’ll start creating our first Android CI workflow in the next part of this series.</p><h3>That all it for now…</h3><p>Lets stop here for now as this is already too much if your just starting out</p><p>Now that you understand the purpose of CI/CD and the terminology behind it, it’s time to build your first pipeline.</p><p>In Part 2, we’ll set up GitHub Actions, create our first workflow, and automatically build an Android application whenever code is pushed to GitHub.</p><p>👋Bye!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91c6e54f0e56" width="1" height="1" alt=""><hr><p><a href="https://blog.watermelonkode.com/android-ci-cd-for-beginners-part-1-introduction-91c6e54f0e56">Android CI/CD for Beginners — #1: Introduction</a> was originally published in <a href="https://blog.watermelonkode.com/">Kotlin Multiplatform Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You’re not a good Indie Developer if you don’t write test cases: I said it.]]></title>
            <link>https://medium.com/@shalenmathew/youre-not-a-good-indie-developer-if-you-don-t-write-test-cases-i-said-it-0ff44839e8b9?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ff44839e8b9</guid>
            <category><![CDATA[indiedev]]></category>
            <category><![CDATA[android-developers]]></category>
            <category><![CDATA[react-native-developers]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 08:15:10 GMT</pubDate>
            <atom:updated>2026-04-27T08:15:10.045Z</atom:updated>
            <content:encoded><![CDATA[<p>Stop mindlessly shipping just because other devs told you to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*by_GJEyhM1ES__3XEIWLoA.png" /></figure><p>I don’t claim to be an expert indie dev, but I am an active one. I’ve spent the last year building <a href="https://github.com/shalenMathew/Quotes-app"><strong>Quotes App</strong></a> and <a href="https://github.com/shalenMathew/MovieFlix_App"><strong>MovieFlix</strong></a>, and honestly, the process taught me more than any tutorial could. With 200+ GitHub stars between them, I figured it was time to share what I’ve learned about the solo dev grind</p><p>Being an indie dev is about wearing a dozen hats, but being a solid developer is the foundation no one talks about. You don’t need to be the next Mark Zuckerberg.</p><p>You just need to understand your project’s whole context so you aren’t spending your weekends frustrated, debugging code that’s failing silently.</p><p>Mastering your project’s context is the ultimate energy saver. It lets you hand off the coding to agents and actually relax, knowing that if something goes sideways, you’ll see it coming a mile away. Less burnout, more shipping.</p><p>As an app developer who markets and builds everything solo, my time and energy are my most important assets. Both are unfortunately limited. You really don’t want to spend your whole life on a single project that is eventually just a gamble. It’s hard to justify spending endless hours of frustration building an app when you don’t even know if it will be worth it yet.</p><p>My main principle for building projects is simple: I want the highest ROI for the lowest amount of time. <strong>Testing is a huge part of that.</strong></p><p>While testing is important early on, it becomes a literal lifesaver once your product succeeds and you start growing a team. When a newbie with zero context starts making changes to your app, that’s usually when all hell breaks loose.</p><p>That is exactly why knowing the basics and being a good developer is so vital. It’s the only way to keep the foundation solid while things are moving fast.</p><h3><strong>Lets Talk about testing :</strong></h3><p>Since I mentioned that time and energy are my most valuable assets, you might think writing tests is just a waste of both.<em> But let me tell you why that’s not true</em>.</p><p>Let me describe a real scenario that happened in 2 of my apps</p><p><a href="https://github.com/shalenMathew/MovieFlix_App"><strong>MovieFlix: A ticking time bomb</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwYIvestfYRJf4qYnQzewg.gif" /></figure><p>I had a feature that scheduled movie notifications, then deleted them from the DB after 10 seconds.</p><p>When i tested manually on my device. The notification popped up. Everything looked fine.</p><p>But when I wrote an automated test, I found a ‘silent killer.’ The background worker was crashing immediately after the notification because it was missing a TypeConverter for the database.</p><p>The failure was invisible. To the user, the notification worked, but under the hood, the database cleanup never happened. ‘Dead data’ was piling up, and because the entry was never deleted, the user would be stuck unable to reschedule that movie ever again.</p><p>This is the trap: the part I could see (the notification) was fine, but the part that mattered for the app’s long-term health was failing silently. Without that test, <strong>I was shipping a time bomb</strong></p><p>That’s exactly where testing becomes vital. When you can’t see the result instantly — like with a scheduled task or an async feature — your result is just a promise for the future. You need to be 100% sure the logic is actually going to deliver that result when the time comes.</p><p><a href="https://github.com/shalenMathew/Quotes-app"><strong>Quotes App: A Hacktoberfest saga</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*BCfJ7KTYf3DK5WRm9JNepg.gif" /></figure><p>Last year, my app was part of Hacktoberfest. It was a win-win: I got help building features I wanted, and other people got the chance to contribute to an open-source project.</p><p>But this is where testing became a non-negotiable part of the process. I was essentially trusting my code to developers who had zero context about how the app worked. When people are jumping in to fix bugs or add features, you need a safety net. You have to make sure that while they’re building something new, they aren’t accidentally breaking the things that already work perfectly.</p><p>To handle this, I added a workflow that runs on every pull request. It automatically checks if the new code breaks any existing features. If the checks pass, I know the code is solid and ready to go.</p><p>This setup was a massive time-saver. I didn’t have to manually review every single PR anymore. If a contribution was low ROI, I’d just merge it as long as the checks passed. That allowed me to stop micromanaging the small stuff and focus my energy on the bigger, more essential features.</p><h3>Ok i showed you why testing is important , but how to do it correctly?</h3><p>Look, don’t try to test everything. Life is way too short to aim for 100% code coverage. You aren’t a massive corporate entity with unlimited resources; you’re a solo dev.</p><p>Focus on the Spine: the core business logic. This is the engine of your app — the data rules, the storage, and the background processes — the core business logic- the reason your users use the app</p><p>I test for High ROI. I don’t waste time testing the ‘Skin’ (the UI) because if a button is missing, I’ll see it the moment I run the app. I spend my time testing the silent logic that I can’t see.</p><p>If your UI has a bug, it’s a glitch. If your business logic has a bug, it’s a data disaster. Stop testing the paint job and start testing the engine. Secure the core, skip the fluff, and ship code that actually works.</p><p>Use AI agents to write your test cases. Don’t start writing them manually from scratch. Today, agents are smart enough to generate the base tests for your project, but you must always cross-check the results.</p><p>Never be completely dependent on them. Like I said, being a good developer is a necessity. When you can delegate the repetitive work to save time and energy, do it.</p><p>That is all from me for today. Bye!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ff44839e8b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I’m Building in Public (And Why You Should Too)]]></title>
            <link>https://medium.com/@shalenmathew/why-im-building-in-public-and-why-you-should-too-ec933f9fd2ef?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec933f9fd2ef</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[hacktoberfest]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 05:48:00 GMT</pubDate>
            <atom:updated>2025-10-24T05:49:12.193Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BtyEfYRF4IRqZDO-" /><figcaption>Photo by <a href="https://unsplash.com/@danist07?utm_source=medium&amp;utm_medium=referral">Danist Soh</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A few months ago, I did something different. I started building in public.</p><p>I’ve built plenty of apps before. Most of them died in my local repository, never seeing the light of day. But this time with my Quotes app, I decided to share every step of the journey online. The wins, the bugs, the “why is this not working” moments. All of it.</p><p>And guess what? The app just hit 50 stars on GitHub.</p><p>That might not sound like much compared to big open source projects, but for me? It was validation. Proof that people actually cared about what I was building.</p><h3>How It Started</h3><p>I’ve always wanted to build a Quotes app. Simple idea, right? But I’d never gotten around to it. This time though, I made a promise to myself: I’d build it in public instead of coding alone in my room like I usually do.</p><p>Android development can get lonely. And frustrating. Really frustrating. So I started posting updates on Twitter and LinkedIn. Shared my struggles with Jetpack Compose. Talked about architecture decisions. Asked for feedback.</p><p>Suddenly, development wasn’t boring anymore. People were watching. Commenting. Suggesting improvements. Some even started using the app.</p><p>That external accountability pushed me to keep going. When you know people are watching, you can’t just abandon the project halfway (well, you technically can, but it feels awkward).</p><h3>The Real Win: Learning in Public</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*BCfJ7KTYf3DK5WRm9JNepg.gif" /></figure><p>Building Quotes app wasn’t just about stars or downloads. It was about leveling up my skills.</p><p>I dove deep into Jetpack Compose. Learned Clean Architecture properly, not just surface level. Started writing actual tests instead of skipping them like before. Improved my understanding of MVVM patterns.</p><p>And here’s the thing: I made the project open source. Because I learned most of what I know from other people’s code. Studying open source projects taught me more than any tutorial ever could. So I wanted to give back.</p><h3>Then Hacktoberfest Happened</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwYIvestfYRJf4qYnQzewg.gif" /></figure><p>Last year during Hacktoberfest, I wanted to contribute to Android projects. But finding good ones was… hard. Most projects were web-focused or had codebases too complex for beginners. There weren’t many Android apps that welcomed newcomers.</p><p>I remember thinking, “Someone should fix this.”</p><p>So this year, I did.</p><p>I opened up both Quotes app and MovieFlix (my movie discovery app) for Hacktoberfest contributions. Clean architecture, modern tech stack, beginner-friendly issues. Everything I wished existed last year.</p><p>The response? Way better than expected.</p><p>Developers started contributing. First-timers made their first PR. Intermediate devs added features. People from different countries, different skill levels, all working on something together.</p><p>It felt good. Really good.</p><p>Quotes app : <a href="https://github.com/shalenMathew/Quotes-app">https://github.com/shalenMathew/Quotes-app</a></p><p>MovieFlix : <a href="https://github.com/shalenMathew/MovieFlix_App">https://github.com/shalenMathew/MovieFlix_App</a></p><h3>Why Building in Public Changed Everything</h3><p>Looking back, sharing my journey publicly was the best decision I made this year.</p><p>I connected with developers way better than me. Learned from their feedback. Got motivation when I felt like quitting. Built projects people actually use.</p><p>And now during Hacktoberfest, I’m on the other side as a maintainer. Helping others the way open source helped me.</p><p>If you’re sitting on a side project right now, afraid to share it because “it’s not perfect yet” or “what if people judge it,” just post it. Tweet about it. Write about your struggles. Share your code.</p><p>The worst that happens? Nothing.</p><p>The best that happens? You build something real, learn faster, meet amazing people, and maybe even help someone else learn too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec933f9fd2ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Testing in Android (Part 1): Unit Testing with JUnit]]></title>
            <link>https://medium.com/@shalenmathew/guide-to-testing-in-android-part-1-unit-testing-with-junit-1f13133c565d?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f13133c565d</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Tue, 13 May 2025 03:42:25 GMT</pubDate>
            <atom:updated>2025-05-20T10:46:33.171Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lL6mS8j4sUUd6u-9gyhV0Q.jpeg" /></figure><p><strong><em>Testing is often underrated in Android development</em></strong>. While it might feel boring or unnecessary for small or personal projects, it becomes essential when building production-ready apps. In real-world scenarios, where multiple developers work on the same codebase, testing ensures your code works as intended, prevents regressions, and catches potential issues early.</p><p>Learning testing can set you apart in the job market, especially in large organizations where strong testing skills add real value and strengthen your resume.</p><p>This is part one of a blog series on testing that I’ll be publishing soon. We’ll begin with Unit testing…will try to keep the blog short , I don’t want to test your patience 😉</p><h3>Lets start with … What is Unit Testing ?</h3><p>Unit testing is the process of testing individual pieces of code, like functions or classes to ensure they work correctly on their own.</p><h3>Then … What is Junit ?</h3><p>JUnit is a testing framework for Java and Kotlin that helps developers write and run unit tests, ensuring that individual parts of their code work as expected.</p><p><strong><em>Lets write a simple unit test for better understanding</em></strong></p><pre>class Helper {<br><br>fun isPalindrome(input: String): Boolean {<br>        var i = 0<br>        var j = input.length - 1<br>        var result = true<br>        while (i &lt; j) {<br>            if (input[i] != input[j]) {<br>                result = false<br>                    break<br>            }<br>            i++<br>            j--<br>        }<br>        return result<br>    }<br>}</pre><p>Here we going to test this simple Palindrome function ( <em>assuming you already know what a palindrome is — if not, feel free to look it up to better understand the logic</em> )</p><p>so we going to test this logic… The whole point of unit testing is to make sure our logic behaves as we intended.</p><p>As you may know, a palindrome is a word that reads the same forwards and backwards. Since we already know this truth about our logic , we’ll write a test to ensure our logic act that way.</p><h3>So lets write our first test …</h3><ol><li>This is how our code look in our IDE</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*06APpEvv78bsXyP6.png" /></figure><p>2. Go to your fun or the class your function in right click on it ,this will open a dialog box like this which you are already familiar with …Go to the <em>Generate</em> section and click on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BurMpAzR9MRWpL90.png" /></figure><p>3. By clicking on <em>Generate</em> it will open a new dialog box click <em>Test</em> in there, as you can see in the image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jo3h0wypOmXbJ98O.png" /></figure><p>4. This will create another dialog box where you need to make 2 changes</p><p>i. keep Testing Library : JUnit4</p><p>ii. click the checkbox as shown in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sqNlCTgsH-kA3wlf.png" /></figure><p>5. This will open another dialog box , make sure you have selected unitTest folder, that where all your test related to unit test will go</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e2QUYozzwk0Da54u.png" /></figure><p>6. This will create a class named HelperTest in the package com.packagname.yourapplicationname(test) as can see in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/0*X60y6EO_stHUuyOK.png" /></figure><p>All the code related to testing will go in there ….</p><p><strong><em>So we are all set to write our first test case…</em></strong></p><p>While writing our unit test , it’s helpful to structure your code in a clear, consistent way. One common approach is the <strong>Arrange, Act, Assert (AAA)</strong> pattern, which organizes your test into three distinct phases:</p><ol><li><strong>Arrange</strong>: Set up the necessary objects and conditions for the test.</li><li><strong>Act</strong>: Perform the action or invoke the method you want to test.</li><li><strong>Assert</strong>: Check if the outcome is as expected.</li></ol><p>First we will <strong><em>Arrange</em></strong> all the necessary objects required for our testing :</p><p>As you know, the function we want to test is in the Helper class, so we need an instance of this class to access the function. To do this, we’ll initialize the object in a special method annotated with @Before. This <strong>annotation</strong> ensures that the <em>method runs before each test is executed, setting up any necessary conditions for the tests</em>.</p><pre>class HelperTest {<br><br>private lateinit var helper: Helper<br>    @Before<br>    fun setUp(){<br>         // ARRANGE<br>        // This function runs before each test case.<br>        // It&#39;s useful for initializing objects and avoiding repeated setup code.<br>        helper=Helper()<br>    }<br>}</pre><p>Now we will test our Palindrome’s logic in a function annotated with @Test</p><pre>class HelperTest {<br><br>private lateinit var helper: Helper<br>    @Before<br>    fun setUp(){<br>        // This function runs before each test case.<br>        // It&#39;s useful for initializing objects and avoiding repeated setup code.<br>        helper=Helper()<br>    }<br>    @Test<br>    fun isPalindrome() {<br>    }<br>}</pre><p>Now we will test our logic inside the above empty function</p><p>We’ll call the isPalindrome function from the Helper class—this is the <strong>Act</strong> phase where we get the result.<br>Then, we&#39;ll check if the result matches our expected outcome</p><p>The whole point of testing is to pass known inputs to a function and check if it returns the expected result.<br>When you already know how the function should behave with specific parameters, you can use that knowledge to confirm it’s working correctly.</p><p>For example, I know for sure that if I pass &quot;level&quot; to the isPalindrome function, it should return true because &quot;level&quot; is a palindrome.<br>Since I already know the expected result, I can use this to verify the function&#39;s behavior.<br><em>If the actual result is different from what I expect, it means there&#39;s likely something wrong with the logic.</em></p><pre>class HelperTest {<br><br>private lateinit var helper: Helper<br>    @Before<br>    fun setUp(){<br>        // This function runs before each test case.<br>        // It&#39;s useful for initializing objects and avoiding repeated setup code.<br>        helper=Helper()<br>    }<br>    @Test<br>    fun isPalindrome() {<br>        // Act<br>        val result = helper.isPalindrome(&quot;level&quot;)<br>    }<br>}</pre><p>In the above code as you can see we are calling our function and storing the returned result in a variable named result</p><p>Now we need to verify that the returned result matches the expected output — this is the <strong>Assert</strong> phase.</p><p>We’ll do this using the assertEquals() function, which takes two parameters: expected result and actual result.<br>If both values match, it means our logic is working as intended.</p><pre>class HelperTest {<br><br>private lateinit var helper: Helper<br>    @Before<br>    fun setUp(){<br>        // This function runs before each test case.<br>        // It&#39;s useful for initializing objects and avoiding repeated setup code.<br>        helper=Helper()<br>    }<br>    @Test<br>    fun isPalindrome() {<br>        // Act<br>        val result = helper.isPalindrome(&quot;level&quot;)<br>      //Assert<br>     // assertEquals(expected, actual)<br>        assertEquals(true,result)<br>    }<br>}</pre><p>now if you run your test case it will show all test passed like this below image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sJnOaVeH898kNqrV.png" /></figure><p>And with that, we’ve successfully written our first test case!<br>Hopefully, this article gave you a basic understanding of how unit testing works in Android using JUnit.</p><p><strong><em>Here are some questions you can solve to improve your understanding of unit testing.</em></strong></p><ol><li><strong>Write a unit test for a password validation function.</strong><br>The function should return true only if the following conditions are met:</li></ol><ul><li>The password is <strong>not empty</strong></li><li>The length is <strong>greater than 6</strong> and <strong>less than 15</strong></li></ul><p>If all conditions are satisfied, the function should return true; otherwise, it should return false.</p><p><strong>2. Write a function to reverse a string without using any library functions.</strong></p><p>That’s all from me for today 😁. If I am lacking somewhere or this article needs some correction just comment down. Byeeee!!!👋</p><p>Follow me on socials :<br><a href="https://x.com/shalenmathew"><strong>X</strong></a> , <a href="http://www.linkedin.com/in/shalen-mathew-3b566921b"><strong>LinkedIn</strong></a> , <a href="https://github.com/shalenMathew"><strong>Github</strong></a>, <a href="https://bsky.app/profile/shalenmathew.bsky.social"><strong>Butterfly</strong></a> <strong>,</strong> <a href="https://linktr.ee/shalenmathew"><strong>Linktree</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f13133c565d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A quick guide into Builder Design Pattern in Android]]></title>
            <link>https://medium.com/@shalenmathew/a-quick-guide-into-builder-design-pattern-in-android-a9ebb786b653?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9ebb786b653</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Sun, 04 May 2025 15:37:09 GMT</pubDate>
            <atom:updated>2025-05-12T11:37:00.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*GSx-86ycaY3S6hfdEhgIiQ.jpeg" /></figure><p><em>This quick guide to the Builder Design Pattern is perfect whether you’re looking for a quick revision or aiming to grasp the concept from scratch</em></p><p>The <strong>Builder Pattern</strong> is a creational design pattern used to <strong>construct complex objects step by step</strong>. It’s especially useful when an object has many <strong>optional fields</strong> or when you want to make object creation more <strong>readable and manageable.</strong></p><p>If a class has many parameters, instead of adding all of them to the constructor and creating a <strong>telescoping constructor</strong>, the <strong>Builder Pattern</strong> provides a better approach by allowing you to add or separate <strong>optional parameters</strong></p><p>Let’s understand with a clear example using the Person class. In this class, there are fields like firstName, lastName, middleName, age, phoneNo, and address. Among these, firstName, lastName, and age are the only mandatory fields.</p><p><strong><em>So without builder pattern it will looks something like this :</em></strong></p><pre>class Person(val firstName: String, val lastName: String, val age: Int) {<br>    // Telescoping constructor for different combinations of parameters<br>    constructor(firstName: String, lastName: String, age: Int, middleName: String) : this(firstName, lastName, age)<br>    constructor(firstName: String, lastName: String, age: Int, middleName: String, phoneNo: String) : this(firstName, lastName, age, middleName)<br>    constructor(firstName: String, lastName: String, age: Int, middleName: String, phoneNo: String, address: String) : this(firstName, lastName, age, middleName, phoneNo)<br>}<br><br><br>fun main() {<br>    val person1 = Person(&quot;John&quot;, &quot;Doe&quot;, 30) // Only mandatory fields<br>    val person2 = Person(&quot;Alice&quot;, &quot;Smith&quot;, 25, &quot;Marie&quot;) // Mandatory + middle name<br>    val person3 = Person(&quot;Bob&quot;, &quot;Johnson&quot;, 40, &quot;David&quot;, &quot;123-456-7890&quot;) // Mandatory + middle name + phone number<br>    val person4 = Person(&quot;Charlie&quot;, &quot;Brown&quot;, 35, &quot;Robert&quot;, &quot;987-654-3210&quot;, &quot;1234 Elm St&quot;) // All fields<br>}</pre><p><strong><em>A better approach to build this class using Builder Pattern :</em></strong></p><pre>fun main() {<br><br>val p1 = Person.PersonBuilder(name = &quot;Shalen&quot;, lastName = &quot;mathew&quot;, age = 22)<br>        .phoneNo(911)<br>        .address(&quot;Banglore&quot;)<br>        .build()<br>}<br><br>data class Person(<br>    val name: String?,<br>    val lastName: String?,<br>    val age: Int?,<br>    val middleName: String?=null,<br>    val phoneNo: Int?=null,<br>    val address: String?=null<br>){<br>    class PersonBuilder(val name: String,val lastName: String,val age: Int){<br>        var middleName: String? = null<br>        var phoneNo:Int? = null<br>        var address:String?=null<br>        fun middleName(middleName: String?) = apply {<br>            this.middleName = middleName<br>        }<br>        fun phoneNo(phoneNo: Int?) = apply {<br>            this.phoneNo = phoneNo<br>        }<br>        fun address(address: String?) = apply {<br>            this.address = address<br>        }<br>        fun build(): Person {<br>            return Person(name, lastName, age, middleName, phoneNo, address)<br>        }<br>    }<br>}</pre><h3>Lets understand what’s going on in the code</h3><p>The Person class has fields like name, lastName, age, middleName, phoneNo, and address. Some of these fields are optional (like middleName, phoneNo, and address).</p><p>Inside the Person class, there&#39;s a PersonBuilder class. This class helps you build a Person object step-by-step. The mandatory field are defined in the constructor of PersonBuilder class</p><p><strong>How It Works</strong>:</p><ul><li>You create a PersonBuilder by passing the <strong>required</strong> fields (name, lastName, age).</li><li>Then, you can optionally add the <strong>optional</strong> fields (middleName, phoneNo, address) using setter methods like .middleName(), .phoneNo(), and .address().</li><li>Each setter method uses apply to set the value and return the builder itself. This allows chaining multiple calls.</li><li>Finally, you call .build() to create the Person object with all the values.</li></ul><h3>Kotlin give a better optimized way to recreate this…while the above code follows a more Java-style implementation</h3><p>In Kotlin, we can use a <strong>data class</strong> to achieve a builder-like effect by defining default values for parameters, making them optional. This eliminates the need for a separate builder class while maintaining flexibility in object creation.</p><pre>data class Person(<br>    val name: String,<br>    val lastName: String,<br>    val age: Int,<br>    val middleName: String? = null,<br>    val phoneNo: Int? = null,<br>    val address: String? = null<br>)<br><br>fun main() {<br>    // Using named arguments for the constructor<br>    val person = Person(<br>        name = &quot;Shalen&quot;, <br>        lastName = &quot;Mathew&quot;, <br>        age = 22, <br>        phoneNo = 911, <br>        address = &quot;Bangalore&quot;<br>    )<br>    <br>    println(person)<br>}</pre><h3>Explanation:</h3><ul><li>The data class Person has both <strong>required</strong> (name, lastName, age) and <strong>optional</strong> (middleName, phoneNo, address) parameters.</li><li>The optional parameters have already being defined with default values (null in this case) , so you can skip them when creating a Person object.</li></ul><p>That’s all from me for today 😁. If I am lacking somewhere or this article needs some correction just comment down. Byeeee!!!👋</p><p>Follow me on socials :<br><a href="https://x.com/shalenmathew"><strong>X</strong></a> , <a href="http://www.linkedin.com/in/shalen-mathew-3b566921b"><strong>LinkedIn</strong></a> , <a href="https://github.com/shalenMathew"><strong>Github</strong></a>, <a href="https://bsky.app/profile/shalenmathew.bsky.social"><strong>Butterfly</strong></a> <strong>,</strong> <a href="https://linktr.ee/shalenmathew"><strong>Linktree</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9ebb786b653" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Using Singleton Design Pattern in Android]]></title>
            <link>https://medium.com/@shalenmathew/a-guide-to-using-singleton-design-pattern-in-android-a9825b8e82ed?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9825b8e82ed</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Wed, 26 Mar 2025 11:28:51 GMT</pubDate>
            <atom:updated>2025-03-26T11:28:51.661Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lL6mS8j4sUUd6u-9gyhV0Q.jpeg" /></figure><p>The Singleton pattern is one of the most commonly used design patterns in Android development. It ensures that a class has only <strong>one instance</strong> throughout the application’s lifecycle and provides a <strong>global point of access</strong> to that instance.</p><p>Imagine a scenario where <strong>Class A</strong> is used in both <strong>Class B</strong> and <strong>Class C.</strong> Without the Singleton pattern, each class would need to create its own instance of Class A, leading to redundant object creation.</p><p>Now, if the number of dependent classes increases, multiple instances of Class A would be created unnecessarily, resulting in inefficient memory usage.</p><p>This is where the <strong>Singleton pattern</strong> comes into play. Instead of creating multiple instances, we create a <strong>single instance of Class A</strong> and share it across all dependent classes, ensuring efficient resource utilization.</p><h3>Why Use Singleton Pattern?</h3><ul><li>Prevents multiple unnecessary instances.</li><li>Ensures a single shared instance is accessible across different parts of the application.</li><li>Useful for managing shared resources like database connections or network clients</li></ul><p><strong><em>Here is an example code of how you will create a singleton instance of any class in Java</em></strong></p><pre>public class A {<br>    private static A instance;<br><br>private A() {}<br>    public static synchronized A getInstance() {<br>        if (instance == null) {<br>            instance = new A();<br>        }<br>        return instance;<br>    }<br>    public void doSomething() {<br>        System.out.println(&quot;Using Singleton Instance of A&quot;);<br>    }<br>}</pre><p>The synchronized keyword ensures thread safety by allowing only one thread at a time to execute this method.</p><p>If multiple threads call getInstance() simultaneously, synchronized ensures that only one thread enters the method at a time.</p><p>This prevents race conditions, where multiple threads might create multiple instances, violating the Singleton pattern.</p><p><strong><em>Singleton Implementation in Kotlin</em></strong></p><p>In Kotlin, we can achieve the same Singleton behavior using the object declaration, which ensures thread safety and avoids unnecessary boilerplate code.</p><pre>object A {<br>    fun doSomething() {<br>        println(&quot;Using Singleton Instance of A&quot;)<br>    }<br>}</pre><p>Here, <strong>A</strong> is a Singleton because object in Kotlin automatically creates a single instance.</p><p><strong><em>Some examples of Singleton in Android</em></strong></p><pre>object NetworkClient {<br>    private val retrofit: Retrofit = Retrofit.Builder()<br>        .baseUrl(&quot;https://api.example.com/&quot;)<br>        .addConverterFactory(GsonConverterFactory.create())<br>        .build()<br><br>fun getRetrofitInstance(): Retrofit {<br>        return retrofit<br>    }<br>}</pre><p>Here, NetworkClient is a Singleton that provides a single instance of Retrofit across the app.</p><h3>Disadvantages of using Singleton Pattern :</h3><ul><li>Multiple classes depending on a shared instance can make testing and modifications harder.</li><li>Holding a reference to an Activity or Context can cause memory leaks if not handled properly.</li><li>Since Singletons act as global state, dependencies may not be explicitly visible, making debugging difficult.</li><li>Improper implementation can lead to race conditions or unnecessary synchronization overhead, affecting performance.</li></ul><p>That’s all from me for today 😁. If I am lacking somewhere or this article needs some correction just comment down. Byeeee!!!👋</p><p>Follow me on socials :<br><a href="https://x.com/shalenmathew">X</a> , <a href="http://www.linkedin.com/in/shalen-mathew-3b566921b">LinkedIn</a> , <a href="https://github.com/shalenMathew">Github</a>, <a href="https://bsky.app/profile/shalenmathew.bsky.social">Butterfly</a> , <a href="https://linktr.ee/shalenmathew">Linktree</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9825b8e82ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick guide to Launch Modes in Android]]></title>
            <link>https://medium.com/@shalenmathew/quick-guide-to-launch-modes-in-android-5688f0209326?source=rss-5cc1f660ff31------2</link>
            <guid isPermaLink="false">https://medium.com/p/5688f0209326</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[shalen mathew]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 16:30:50 GMT</pubDate>
            <atom:updated>2025-03-17T11:56:51.420Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKbOXTCPqt5VVNL01TY4NA.jpeg" /></figure><p>Launch modes in Android define how <strong>activities are created and managed</strong> in the task stack when they are opened</p><p>Launch modes are mainly defined in the manifest within an activity’s declaration but can also be set using Intent flags in code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXFNsOLuZnTU4HWgd4npxw.png" /></figure><p>Here are the 4 types of launch modes in Android :</p><p>1️⃣ <strong>Standard</strong><br>2️⃣ <strong>SingleTop</strong><br>3️⃣ <strong>SingleTask</strong><br>4️⃣ <strong>SingleInstance</strong></p><p>Lets have a quick overview on each one of them :</p><h3>1. Standard :</h3><p>In <strong>Standard</strong> launch mode, every time you launch an activity, a <strong>new instance</strong> is created, <strong>even if an existing instance already exists in the stack</strong>.</p><p>For example, if you open Activity A multiple times, the system will create a new instance each time instead of reusing an existing one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*JITN_o9lPrmVhWxA.png" /></figure><p>In the image above, imagine each element in the stack represents a different activity. In <strong>Standard</strong> launch mode, <strong>every time</strong> you open an activity, <strong>a new instance is created</strong>, regardless of whether an existing instance already exists in the stack.</p><p>This is the default launch behavior of an activity</p><h3>2. SingleTop :</h3><p>If you launch an activity with singleTop(), a <strong>new instance will not be created</strong> if the activity is already at the <strong>top of the stack</strong>. Instead, the existing instance will handle the new intent through onNewIntent(). However, if the activity <strong>is not the topmost one</strong>, a <strong>new instance will be created</strong>.</p><p>( <em>If you’re wondering</em> <em>what is</em> onNewIntent() <em>then</em> <em>a new intent brings new data or new instructions to an already running activity without creating a new instance.</em></p><p><em>E.g — Imagine you’re reading an article in a news app (</em>NewsActivity <em>with</em> singleTop<em>). If you open another article:</em></p><ul><li><em>Instead of creating a new</em> NewsActivity<em>,</em> onNewIntent() <em>is triggered.</em></li><li><em>The activity updates with the new article instead of restarting.)</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*SuhwkYC6KJWxepyy.png" /></figure><p>Imagine you launched <strong>Activity A</strong> with singleTop. Since <strong>Activity A</strong> is already at the top of the stack, a new instance won’t be created. A single instance of <strong>Activity A</strong> will be always at the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*_59huyPJJOlv4wyz.png" /></figure><p>Now, let’s assume Activity B was launched (as u can see on the left image), so Activity A is no longer at the top of the stack. If we launch Activity A again (which has singleTop), a new instance will be created because it is not at the top.</p><h3>3. SingleTask :</h3><p>In singleTask mode, if an instance of the activity <strong>already exists anywhere in the task</strong>, Android <strong>reuses</strong> that instance <strong>instead of creating a new one</strong>. However, all activities <strong>above it</strong> in the stack are <strong>cleared</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*A1Cq7CnY7cjNHMY2.png" /></figure><p>Imagine there are multiple activities in the stack — <strong>A, B, C,D and E</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*JU9OFCaO3dKEz0z5.png" /></figure><p>Now, if we launch <strong>Activity C</strong> with singleTask, and an instance of <strong>Activity C</strong> already exists in the stack, instead of creating a new instance, Android will <strong>clear all activities above it</strong> and bring <strong>Activity C</strong> to the top.</p><h3>4. SingleInstance :</h3><p>If you launch an activity with singleInstance, it always runs in a <strong>separate task</strong> and remains the <strong>only</strong> activity in that task. No other activities can be launched into the same task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*1IQl4EgXGz1V8DZq.png" /></figure><p>Imagine there are multiple activities in the stack — <strong>A, B and C</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*3Az5o-IMjcuo07bi.png" /></figure><p>Now, if you launch <strong>Activity D</strong> with singleInstance, it will create a <strong>new task</strong>, and <strong>D</strong> will be the <strong>only</strong> activity in that task. No other activities can be launched into it.</p><p><em>Now, let’s summarize what we’ve learned so far:</em></p><ul><li><strong>Standard</strong> → A new instance is created <strong>every time</strong>, even if one already exists.</li><li><strong>SingleTop</strong> → If the activity is <strong>already on top</strong>, no new instance is created; otherwise, a new instance is launched.</li><li><strong>SingleTask</strong> → If an instance exists <strong>anywhere in the stack</strong>, it is <strong>brought to the top</strong>, and <strong>all activities above it are cleared</strong>.</li><li><strong>SingleInstance</strong> → The activity <strong>always runs in its own task</strong>, and <strong>no other activities can be launched into it</strong>.</li></ul><p>That’s all from me for today 😁. If I am lacking somewhere or this article needs some correction just comment down. Bye!!!👋</p><p>Follow me on socials :<br><a href="https://x.com/shalenmathew">X</a> , <a href="http://www.linkedin.com/in/shalen-mathew-3b566921b">LinkedIn</a> , <a href="https://github.com/shalenMathew">Github</a>, <a href="https://bsky.app/profile/shalenmathew.bsky.social">Butterfly</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5688f0209326" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>