<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AhsanAhmed03</title>
    <description>The latest articles on DEV Community by AhsanAhmed03 (@ahsanahmed03).</description>
    <link>https://dev.to/ahsanahmed03</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1097616%2F857c809f-ff83-4512-a680-5e8ac5aa634f.jpeg</url>
      <title>DEV Community: AhsanAhmed03</title>
      <link>https://dev.to/ahsanahmed03</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahsanahmed03"/>
    <language>en</language>
    <item>
      <title>Top Causes of ANRs in Android and How to Eliminate Them (Complete Developer Guide)</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Mon, 06 Apr 2026 18:33:15 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/top-causes-of-anrs-in-android-and-how-to-eliminate-them-complete-developer-guide-16kj</link>
      <guid>https://dev.to/ahsanahmed03/top-causes-of-anrs-in-android-and-how-to-eliminate-them-complete-developer-guide-16kj</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f4zkw2535y6fvdja81v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f4zkw2535y6fvdja81v.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine a user opens your Android app, taps a button, and nothing happens.&lt;/p&gt;

&lt;p&gt;The screen freezes.&lt;/p&gt;

&lt;p&gt;After a few seconds, Android shows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Application Not Responding (ANR)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most users don’t wait.&lt;/p&gt;

&lt;p&gt;They close the app and uninstall it.&lt;/p&gt;

&lt;p&gt;That’s why ANRs are one of the most dangerous performance issues in Android apps.&lt;/p&gt;

&lt;p&gt;According to Android Developers documentation, ANRs happen when the main thread is blocked and cannot respond to user input within a specific time.&lt;/p&gt;

&lt;p&gt;And if your ANR rate becomes high, Google Play can reduce your app visibility.&lt;/p&gt;

&lt;p&gt;So understanding ANRs is not optional — it’s critical.&lt;/p&gt;

&lt;p&gt;**What is an ANR? (Simple Explanation)&lt;/p&gt;

&lt;p&gt;Official Definition**&lt;/p&gt;

&lt;p&gt;ANR occurs when the UI thread is blocked and cannot process user input or draw frames.&lt;/p&gt;

&lt;p&gt;Android shows ANR when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input event not handled within 5 seconds&lt;/li&gt;
&lt;li&gt;BroadcastReceiver runs too long&lt;/li&gt;
&lt;li&gt;Service takes too long to start&lt;/li&gt;
&lt;li&gt;Job or foreground service delays response&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think of your app like a restaurant.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI Thread = Waiter&lt;/li&gt;
&lt;li&gt;Background Thread = Kitchen&lt;/li&gt;
&lt;li&gt;User = Customer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Good Flow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Customer orders → Waiter sends to kitchen → Kitchen prepares → Waiter delivers&lt;/p&gt;

&lt;p&gt;Everything runs smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bad Flow (ANR)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Customer orders → Waiter goes to kitchen and starts cooking himself&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No one takes new orders&lt;/li&gt;
&lt;li&gt;No one serves food&lt;/li&gt;
&lt;li&gt;Restaurant stops working&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly what happens when UI thread does heavy work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top Causes of ANRs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Heavy Work on Main Thread ❌&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Running:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network calls&lt;/li&gt;
&lt;li&gt;Database queries&lt;/li&gt;
&lt;li&gt;File reading&lt;/li&gt;
&lt;li&gt;JSON parsing&lt;/li&gt;
&lt;li&gt;Image processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;on UI thread.&lt;/p&gt;

&lt;p&gt;Android documentation clearly states:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep main thread unblocked and move heavy work to worker threads&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2. Long Database or Network Operations ❌&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;data&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// running on main thread&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This blocks UI.&lt;/p&gt;

&lt;p&gt;Result → ANR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. BroadcastReceiver Doing Heavy Work ❌&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;BroadcastReceiver should do small quick tasks only.&lt;/p&gt;

&lt;p&gt;If it runs too long → ANR.&lt;/p&gt;

&lt;p&gt;Android recommends moving work to background threads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Service Not Starting in Time ❌&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Foreground service must call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nf"&gt;startForeground&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;within 5 seconds.&lt;/p&gt;

&lt;p&gt;Otherwise → ANR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Deadlocks and Thread Blocking ❌&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Thread A waiting for Thread B&lt;br&gt;
Thread B waiting for Thread A&lt;/p&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;p&gt;App freezes.&lt;/p&gt;

&lt;p&gt;Android documentation calls this deadlock, a major ANR cause.&lt;/p&gt;

&lt;p&gt;**Common Developer Mistakes&lt;/p&gt;

&lt;p&gt;❌ Running API calls in Activity**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;users&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wrong approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌ Large JSON parsing on UI thread&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;json&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"data.json"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;readText&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ANR risk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best Practices to Avoid ANRs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Use Coroutines&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="n"&gt;viewModelScope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;users&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moves work off main thread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Use Dispatchers.IO&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nf"&gt;withContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Optimized for I/O.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Use Flow for Continuous Data&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsersFlow&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flowOn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Efficient and non-blocking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Use WorkManager for Background Tasks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Good for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sync&lt;/li&gt;
&lt;li&gt;Upload&lt;/li&gt;
&lt;li&gt;Downloads&lt;/li&gt;
&lt;li&gt;Scheduling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;✅ Keep BroadcastReceiver Lightweight&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onReceive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Intent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nc"&gt;CoroutineScope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Modern Kotlin Code Example&lt;br&gt;
Repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;UserApi&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;withContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ViewModel&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@HiltViewModel&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserViewModel&lt;/span&gt; &lt;span class="nd"&gt;@Inject&lt;/span&gt; &lt;span class="k"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;UserRepository&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewModel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;_users&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MutableStateFlow&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;(&lt;/span&gt;&lt;span class="nf"&gt;emptyList&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;users&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asStateFlow&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nf"&gt;init&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;loadUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;loadUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;viewModelScope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;_users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Jetpack Compose UI&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;UserScreen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;viewModel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;UserViewModel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;users&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;viewModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collectAsState&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nc"&gt;LazyColumn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Real-World Use Case&lt;br&gt;
Video Fetching App&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scenario:&lt;/p&gt;

&lt;p&gt;App scans device videos.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrong&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scanning files in Activity.&lt;/p&gt;

&lt;p&gt;UI freezes.&lt;/p&gt;

&lt;p&gt;ANR occurs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Correct&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Splash loads videos&lt;/li&gt;
&lt;li&gt;Repository uses Dispatchers.IO&lt;/li&gt;
&lt;li&gt;Flow emits data&lt;/li&gt;
&lt;li&gt;UI updates smoothly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;p&gt;✔ No ANR&lt;br&gt;
✔ Smooth scrolling&lt;br&gt;
✔ Fast loading&lt;br&gt;
✔ Better Play Store rating&lt;/p&gt;

&lt;p&gt;**Key Takeaways&lt;/p&gt;

&lt;p&gt;Core Rule**&lt;/p&gt;

&lt;p&gt;Never block the main thread&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Points&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✔ UI thread must always be free&lt;br&gt;
✔ Move heavy work to background threads&lt;br&gt;
✔ Use Coroutines and Flow&lt;br&gt;
✔ Keep BroadcastReceiver lightweight&lt;br&gt;
✔ Use WorkManager for long tasks&lt;br&gt;
✔ Avoid deadlocks and thread blocking&lt;br&gt;
✔ Monitor ANR in Play Console&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ANRs are not just performance issues.&lt;/p&gt;

&lt;p&gt;They directly impact:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User experience&lt;/li&gt;
&lt;li&gt;App rating&lt;/li&gt;
&lt;li&gt;Play Store ranking&lt;/li&gt;
&lt;li&gt;Revenue&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The safest strategy is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep the UI thread clean and move all heavy work to background threads.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you follow Android’s official guidelines and modern Kotlin practices, ANRs can be almost eliminated.&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>android</category>
      <category>androiddev</category>
      <category>anr</category>
      <category>developer</category>
    </item>
    <item>
      <title>🚀 Why Your Android App is Slow (And How to Fix It)</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Mon, 06 Apr 2026 18:07:29 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/why-your-android-app-is-slow-and-how-to-fix-it-p5f</link>
      <guid>https://dev.to/ahsanahmed03/why-your-android-app-is-slow-and-how-to-fix-it-p5f</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexe0crf7xezimfmlzr0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexe0crf7xezimfmlzr0u.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You launch your app…&lt;br&gt;
It takes 3 seconds to open.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You scroll a list…&lt;br&gt;
It lags and stutters.&lt;/p&gt;

&lt;p&gt;You tap a button…&lt;br&gt;
Nothing happens for a moment.&lt;/p&gt;

&lt;p&gt;Sound familiar?&lt;/p&gt;

&lt;p&gt;If yes, your app isn’t just “a bit slow” — it’s silently losing users.&lt;/p&gt;

&lt;p&gt;👉 Studies show users uninstall apps that feel sluggish within minutes.&lt;/p&gt;

&lt;p&gt;The good news?&lt;br&gt;
Most performance issues in Android apps are predictable and fixable — once you understand what’s happening under the hood.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Deep Dive: Why Android Apps Become Slow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s simplify how Android works internally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 The Main Thread (UI Thread)&lt;/strong&gt;&lt;br&gt;
Think of your app like a restaurant kitchen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Main Thread = the chef&lt;/li&gt;
&lt;li&gt;UI rendering, clicks, animations = orders&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 If the chef is busy doing something heavy (like calculating data or loading images), new orders get delayed.&lt;/p&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI freezes&lt;/li&gt;
&lt;li&gt;Laggy scrolling&lt;/li&gt;
&lt;li&gt;ANRs (Application Not Responding)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;⏱️ The 16ms Rule&lt;/strong&gt;&lt;br&gt;
Android tries to render 60 frames per second.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each frame must be drawn in 16ms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your app takes longer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frames drop ❌&lt;/li&gt;
&lt;li&gt;UI becomes janky ❌&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🔥 Common Causes of Slowness&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Problem: Heavy work on Main Thread&lt;br&gt;
Why: Blocks UI&lt;/p&gt;

&lt;p&gt;Problem: Unoptimized RecyclerView&lt;br&gt;
Why: Rebinding too much&lt;/p&gt;

&lt;p&gt;Problem: Memory leaks&lt;br&gt;
Why: App slows over time&lt;/p&gt;

&lt;p&gt;Problem: Too many recompositions (Compose)&lt;br&gt;
Why: Extra rendering&lt;/p&gt;

&lt;p&gt;Problem: Large images&lt;br&gt;
Why: High memory + slow decoding&lt;/p&gt;

&lt;p&gt;Problem: Bad architecture&lt;br&gt;
Why: Uncontrolled state updates&lt;/p&gt;

&lt;p&gt;**🛠️ Fix #1: Move Work Off the Main Thread (Coroutines)&lt;/p&gt;

&lt;p&gt;❌ Bad Example (UI Freeze)**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;loadData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;data&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getDataFromNetwork&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Blocking call&lt;/span&gt;
    &lt;span class="n"&gt;textView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 This blocks UI.&lt;/p&gt;

&lt;p&gt;**✅ Good Example (Using Coroutines)&lt;/p&gt;

&lt;p&gt;ViewModel (Best Practice)**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MainViewModel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DataRepository&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewModel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;_data&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MutableStateFlow&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;StateFlow&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_data&lt;/span&gt;

    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;loadData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;viewModelScope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;withContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getDataFromNetwork&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="n"&gt;_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Why this works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dispatchers.IO → runs in background thread&lt;/li&gt;
&lt;li&gt;viewModelScope → lifecycle-safe (no leaks)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**🧱 Fix #2: Optimize RecyclerView (XML)&lt;/p&gt;

&lt;p&gt;❌ Common Mistakes**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not using DiffUtil&lt;/li&gt;
&lt;li&gt;Calling notifyDataSetChanged()&lt;/li&gt;
&lt;li&gt;Heavy work in onBindViewHolder&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;✅ Use ListAdapter + DiffUtil&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserAdapter&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ListAdapter&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;UserAdapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="nc"&gt;DiffCallback&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ItemUserBinding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nc"&gt;RecyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreateViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewGroup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;viewType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;ViewHolder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;binding&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ItemUserBinding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inflate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nc"&gt;LayoutInflater&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onBindViewHolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;holder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewHolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;user&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;holder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DiffCallback&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DiffUtil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ItemCallback&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;areItemsTheSame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;areContentsTheSame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Why this is fast:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only updates changed items&lt;/li&gt;
&lt;li&gt;Avoids full list redraw&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**⚡ Fix #3: Jetpack Compose Performance&lt;/p&gt;

&lt;p&gt;❌ Bad Compose Code**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;UserScreen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No lazy loading&lt;/li&gt;
&lt;li&gt;Renders everything at once&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;✅ Use LazyColumn *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;UserScreen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;LazyColumn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🔁 Avoid Unnecessary Recompositions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;UserItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;remember&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 remember prevents recomputation.&lt;/p&gt;

&lt;p&gt;**🧠 Fix #4: Memory Leaks (Silent Killer)&lt;/p&gt;

&lt;p&gt;❌ Common Leak**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Singleton&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;lateinit&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Holding Activity context = memory leak.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Correct Way&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Singleton&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;lateinit&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;

    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appContext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;appContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;applicationContext&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;💡 Use LeakCanary&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;&lt;span class="n"&gt;debugImplementation&lt;/span&gt; &lt;span class="s2"&gt;"com.squareup.leakcanary:leakcanary-android:2.12"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Detects memory leaks automatically.&lt;/p&gt;

&lt;p&gt;**🖼️ Fix #5: Image Optimization&lt;/p&gt;

&lt;p&gt;❌ Problem**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loading full-size images&lt;/li&gt;
&lt;li&gt;No caching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;✅ Use Coil (Modern Best Practice)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;&lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s2"&gt;"io.coil-kt:coil-compose:2.5.0"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nc"&gt;AsyncImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://example.com/image.jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contentDescription&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auto caching&lt;/li&gt;
&lt;li&gt;Efficient decoding&lt;/li&gt;
&lt;li&gt;Works with Compose&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🧱 Fix #6: Avoid Overdraw&lt;/strong&gt;&lt;br&gt;
👉 Overdraw = drawing pixels multiple times&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use fewer nested layouts&lt;/li&gt;
&lt;li&gt;Avoid unnecessary backgrounds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;⚡ Fix #7: Use Baseline Profiles (Advanced 🚀)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Speeds up app startup significantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependency&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;&lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s2"&gt;"androidx.profileinstaller:profileinstaller:1.3.1"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Pre-compiles critical code paths.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🚨 Edge Cases &amp;amp; Real Problems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. ANR (Application Not Responding)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Caused by blocking UI thread &amp;gt; 5 seconds&lt;/li&gt;
&lt;li&gt;Fix → Move work to background&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Too Many API Calls&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use caching (Room / memory cache)&lt;/li&gt;
&lt;li&gt;Debounce user input&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. ViewBinding Leaks (Important ⚠️)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;_binding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FragmentMainBinding&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;binding&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_binding&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onDestroyView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_binding&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Prevents fragment leaks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Compose + State Explosion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Avoid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;state&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="nf"&gt;mutableStateOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="p"&gt;.)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;inside large composables without scoping.&lt;/p&gt;

&lt;p&gt;👉 Use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ViewModel&lt;/li&gt;
&lt;li&gt;StateFlow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🧩 Architecture Matters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Bad architecture = performance issues&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended Stack:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MVVM&lt;/li&gt;
&lt;li&gt;StateFlow&lt;/li&gt;
&lt;li&gt;Repository pattern&lt;/li&gt;
&lt;li&gt;Single source of truth&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📊 Quick Performance Checklist&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ No heavy work on Main Thread&lt;br&gt;
✅ Use LazyColumn / RecyclerView properly&lt;br&gt;
✅ Optimize images&lt;br&gt;
✅ Avoid memory leaks&lt;br&gt;
✅ Minimize recompositions&lt;br&gt;
✅ Use background threads&lt;br&gt;
✅ Use profiling tools (Android Studio Profiler)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎯 Final Thought&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Performance is not something you “add later.”&lt;/p&gt;

&lt;p&gt;It’s something you &lt;strong&gt;design from day one.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A fast app feels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Premium 💎&lt;/li&gt;
&lt;li&gt;Reliable 🔒&lt;/li&gt;
&lt;li&gt;Professional 🚀&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;💬 Your Challenge&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Open your current project and answer this:&lt;/p&gt;

&lt;p&gt;“Where am I blocking the main thread without realizing it?”&lt;/p&gt;

&lt;p&gt;OR&lt;/p&gt;

&lt;p&gt;“How many unnecessary recompositions are happening in my Compose UI?”&lt;/p&gt;

&lt;p&gt;Drop your answer in the comments 👇&lt;br&gt;
Let’s debug together.&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>androiddev</category>
    </item>
    <item>
      <title>Networking in Android: Why Ktor is the Modern Choice for Kotlin Developers</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Tue, 31 Mar 2026 14:59:16 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/networking-in-android-why-ktor-is-the-modern-choice-for-kotlin-developers-10n</link>
      <guid>https://dev.to/ahsanahmed03/networking-in-android-why-ktor-is-the-modern-choice-for-kotlin-developers-10n</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fru566uuhbr6gcholl287.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fru566uuhbr6gcholl287.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you still using Retrofit because “that’s how it’s always been done”? It’s time to look at a networking engine built from the ground up for Kotlin Multiplatform and Coroutines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
For years, Retrofit has been the undisputed king of Android networking. But as the ecosystem shifts toward Kotlin Multiplatform (KMP) and Compose Multiplatform, we need a tool that speaks “native Kotlin.”&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;Ktor&lt;/strong&gt;. Developed by JetBrains, Ktor is a lightweight, asynchronous framework that allows you to build both servers and clients. In Android, the Ktor Client provides a flexible, coroutine-powered way to handle API calls with less “magic” and more control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Switch to Ktor?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiplatform Ready: Use the same networking code for Android, iOS, Desktop, and Web.&lt;/li&gt;
&lt;li&gt;Coroutine First: No more adapters or complex wrappers; it works with suspend functions out of the box.&lt;/li&gt;
&lt;li&gt;Modular: You only install the features you need (Logging, Content Negotiation, Auth), keeping your app lean.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Setting Up Ktor in Android&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To get started, add these dependencies to your &lt;strong&gt;libs.versions.toml&lt;/strong&gt; or &lt;strong&gt;build.gradle.kts&lt;/strong&gt; file. We’ll use the Android engine and Serialization for JSON parsing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Dependencies (Simplified)&lt;/span&gt;
&lt;span class="nf"&gt;implementation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"io.ktor:ktor-client-android:2.3.x"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;implementation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"io.ktor:ktor-client-content-negotiation:2.3.x"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;implementation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"io.ktor:ktor-serialization-kotlinx-json:2.3.x"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;implementation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"io.ktor:ktor-client-logging:2.3.x"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Practical Implementation: The “Ktor Way”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Following modern Android architecture (MVVM), here is how you define a clean, production-ready API client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Data Model&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Serializable&lt;/span&gt;
&lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. The Ktor Client Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike Retrofit interfaces, Ktor uses a functional approach.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;KtorClient&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;httpClient&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;HttpClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Android&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// 1. JSON Parsing&lt;/span&gt;
        &lt;span class="nf"&gt;install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ContentNegotiation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Json&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;prettyPrint&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;
                &lt;span class="n"&gt;ignoreUnknownKeys&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// 2. Logging for debugging&lt;/span&gt;
        &lt;span class="nf"&gt;install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Logging&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LogLevel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BODY&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// 3. Default Request configuration&lt;/span&gt;
        &lt;span class="nf"&gt;defaultRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://jsonplaceholder.typicode.com/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ContentType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ContentType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. The Repository and ViewModel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using StateFlow and Coroutines to fetch data safely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostRepository&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;KtorClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;httpClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"posts"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;body&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostViewModel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PostRepository&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PostRepository&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewModel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;_posts&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MutableStateFlow&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;(&lt;/span&gt;&lt;span class="nf"&gt;emptyList&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;posts&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asStateFlow&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;fetchPosts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;viewModelScope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;_posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Handle errors (Timeout, Connectivity, etc.)&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Best Practices&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Close the Client:&lt;/strong&gt; Always close the HttpClient when it’s no longer needed (though in a singleton Android app, it usually lives with the App lifecycle).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Plugins:&lt;/strong&gt; Don’t write manual JSON parsers; use the ContentNegotiation plugin.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Platform Engines:&lt;/strong&gt; Use CIO (Coroutine-based I/O) for high performance or Android for better integration with system proxy settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common Mistakes to Avoid&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hardcoding URLs:&lt;/strong&gt; Use the defaultRequest block to manage base URLs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blocking the Main Thread:&lt;/strong&gt; Ktor is asynchronous, but always ensure your calls are wrapped in a viewModelScope or appropriate Coroutine Scope.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting ProGuard Rules:&lt;/strong&gt; If you use Kotlinx Serialization, ensure your ProGuard rules keep your @Serializable classes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Ktor isn’t just a “Retrofit alternative” — it’s the future of Kotlin networking. It offers more flexibility and is essential if you ever plan to share your logic with an iOS app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do you think?&lt;/strong&gt; Have you tried Ktor in a production Android app yet, or are you sticking with Retrofit for now? Let’s chat in the comments!&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>android</category>
      <category>androiddevelopment</category>
      <category>networking</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>Android XML vs Jetpack Compose — Which One Should You Use in 2026?</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Mon, 30 Mar 2026 18:41:33 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/android-xml-vs-jetpack-compose-which-one-should-you-use-in-2026-2pi1</link>
      <guid>https://dev.to/ahsanahmed03/android-xml-vs-jetpack-compose-which-one-should-you-use-in-2026-2pi1</guid>
      <description>&lt;p&gt;Every Android Developer Faces This&lt;/p&gt;

&lt;p&gt;You open a new Android project and get stuck at one question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Should I use XML or Jetpack Compose?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you’ve been working with Android for a while, XML feels familiar. It’s stable, predictable, and widely used.&lt;/p&gt;

&lt;p&gt;But then you see Jetpack Compose — modern, Kotlin-first, less boilerplate, and backed heavily by Google.&lt;/p&gt;

&lt;p&gt;Now the confusion starts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is XML outdated?&lt;/li&gt;
&lt;li&gt;Is Compose production-ready?&lt;/li&gt;
&lt;li&gt;Which one is better for performance?&lt;/li&gt;
&lt;li&gt;What should I use in real apps?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s break it down deeply, but simply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Understanding the Core Difference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🏗️ XML (View System)&lt;/p&gt;

&lt;p&gt;Think of XML like designing a house blueprint separately from construction.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI is written in XML files&lt;/li&gt;
&lt;li&gt;Logic is written in Kotlin/Java&lt;/li&gt;
&lt;li&gt;You connect them using findViewById or ViewBinding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Two separate worlds:&lt;/p&gt;

&lt;p&gt;XML → UI&lt;br&gt;
Kotlin → Logic&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚡ Jetpack Compose&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compose is like building the house directly in code, live, and reactive.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI is written in Kotlin&lt;/li&gt;
&lt;li&gt;No XML at all&lt;/li&gt;
&lt;li&gt;UI automatically updates when data changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Single source of truth:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kotlin handles everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔍 Deep Dive (Based on Official Android Architecture)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;XML (View System Internals)&lt;/li&gt;
&lt;li&gt;Uses View hierarchy (ViewGroup → View)&lt;/li&gt;
&lt;li&gt;UI rendering happens via:&lt;/li&gt;
&lt;li&gt;Measure → Layout → Draw&lt;/li&gt;
&lt;li&gt;Heavy nesting = performance cost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Problem:&lt;/p&gt;

&lt;p&gt;Updating UI manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="n"&gt;textView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello"&lt;/span&gt;
&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;visibility&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GONE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 You control everything manually.&lt;/p&gt;

&lt;p&gt;Jetpack Compose Internals&lt;/p&gt;

&lt;p&gt;Compose works on Declarative UI + State-driven rendering&lt;/p&gt;

&lt;p&gt;Core Concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Composable Functions&lt;/li&gt;
&lt;li&gt;State&lt;/li&gt;
&lt;li&gt;Recomposition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You describe UI as a function&lt;/li&gt;
&lt;li&gt;When state changes → Compose redraws only affected parts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Think like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;Greeting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello $name"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If name changes → UI updates automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ Implementation (Production-Ready Examples)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧱 XML Example (Classic UI)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gradle&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;&lt;span class="n"&gt;android&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;buildFeatures&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;viewBinding&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;layout/activity_main.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt;
    &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
    &lt;span class="na"&gt;android:orientation=&lt;/span&gt;&lt;span class="s"&gt;"vertical"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/tvTitle"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Hello XML"&lt;/span&gt;
        &lt;span class="na"&gt;android:textSize=&lt;/span&gt;&lt;span class="s"&gt;"20sp"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/btnClick"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Click Me"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;MainActivity.kt&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MainActivity&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AppCompatActivity&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;lateinit&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ActivityMainBinding&lt;/span&gt; &lt;span class="c1"&gt;// Avoid findViewById&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bundle&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;binding&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ActivityMainBinding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inflate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;layoutInflater&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;setContentView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;btnClick&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setOnClickListener&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tvTitle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Clicked!"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;⚠️ Issues in XML Approach&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Boilerplate code&lt;/li&gt;
&lt;li&gt;Manual UI updates&lt;/li&gt;
&lt;li&gt;Risk of memory leaks (if binding mishandled)&lt;/li&gt;
&lt;li&gt;Hard to maintain large UI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;⚡ Jetpack Compose Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gradle"&gt;&lt;code&gt;&lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s2"&gt;"androidx.compose.ui:ui:1.6.0"&lt;/span&gt;
&lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s2"&gt;"androidx.compose.material3:material3:1.2.0"&lt;/span&gt;
&lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s2"&gt;"androidx.activity:activity-compose:1.8.2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MainActivity.kt&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MainActivity&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ComponentActivity&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bundle&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;setContent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;UI Code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;text&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="nf"&gt;remember&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;mutableStateOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello Compose"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;modifier&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Modifier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillMaxSize&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="n"&gt;verticalArrangement&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Arrangement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;horizontalAlignment&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Alignment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CenterHorizontally&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;fontSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sp&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;onClick&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Clicked!"&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Click Me"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔥 Why This Is Better&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No XML&lt;/li&gt;
&lt;li&gt;No binding&lt;/li&gt;
&lt;li&gt;No manual UI updates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;State-driven UI&lt;br&gt;
👉 UI reacts automatically&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚠️ Edge Cases &amp;amp; Real-World Considerations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Performance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XML:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster initial load&lt;/li&gt;
&lt;li&gt;Heavy layouts = slow rendering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slight startup overhead&lt;/li&gt;
&lt;li&gt;Faster updates due to recomposition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;👉 Best Practice:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Avoid unnecessary recompositions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use remember, derivedStateOf

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Memory Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XML:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Risk of leaks with binding&lt;/li&gt;
&lt;li&gt;Fragment lifecycle issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lifecycle-aware by default&lt;/li&gt;
&lt;li&gt;Safer memory handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Compose reduces leak chances significantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Large Projects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XML:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hard to scale&lt;/li&gt;
&lt;li&gt;Multiple files → difficult navigation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modular UI&lt;/li&gt;
&lt;li&gt;Reusable components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Interoperability (IMPORTANT)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You don’t need to fully switch.&lt;/p&gt;

&lt;p&gt;👉 You can mix both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nf"&gt;setContent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;AndroidView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class="nc"&gt;LayoutInflater&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;inflate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old_layout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧠 When Should You Use What?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use XML if:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Maintaining legacy apps&lt;/li&gt;
&lt;li&gt;Team not trained in Compose&lt;/li&gt;
&lt;li&gt;Simple static UI&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Use Compose if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Starting a new project&lt;/li&gt;
&lt;li&gt;Building scalable UI&lt;/li&gt;
&lt;li&gt;Want modern architecture&lt;/li&gt;
&lt;li&gt;Using Kotlin fully&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🏁 Final Verdict&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 XML is stable and proven&lt;/p&gt;

&lt;p&gt;👉 Compose is the future&lt;/p&gt;

&lt;p&gt;Google is clearly pushing Compose:&lt;/p&gt;

&lt;p&gt;New libraries → Compose-first&lt;br&gt;
Material 3 → Compose-first&lt;br&gt;
Updates → Compose-focused&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎯 Challenge for You&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Have you tried migrating an XML screen to Compose?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What problems did you face?&lt;/li&gt;
&lt;li&gt;Did performance improve or not?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💬 Drop your experience in comments — let’s learn from real-world cases.&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>android</category>
      <category>jetpackcompose</category>
      <category>kotlin</category>
      <category>development</category>
    </item>
    <item>
      <title>Understanding Flows in Android: A Simple Guide with Examples</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Tue, 03 Dec 2024 17:21:16 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/understanding-flows-in-android-a-simple-guide-with-examples-o8e</link>
      <guid>https://dev.to/ahsanahmed03/understanding-flows-in-android-a-simple-guide-with-examples-o8e</guid>
      <description>&lt;p&gt;When building Android apps, you often deal with data that changes over time — like user input, API responses, or database updates. Handling these changes efficiently and reactively can be tricky. That’s where Kotlin Flows come in!&lt;/p&gt;

&lt;p&gt;Kotlin Flows are a powerful tool for working with streams of data asynchronously. They’re part of Kotlin’s coroutines framework, designed to handle data that flows over time, making your code clean, efficient, and reactive.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Flows?
&lt;/h2&gt;

&lt;p&gt;Think of Flows as a stream of data that emits values over time. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A flow might emit values when a database gets updated.&lt;/li&gt;
&lt;li&gt;It could emit a new value every time a user enters text in a search bar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flows are &lt;strong&gt;cold&lt;/strong&gt; by default, meaning they don’t start emitting values until they are collected. This makes them efficient since no work is done unless there’s a listener (collector).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Flows?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Simplify Asynchronous Tasks:&lt;/strong&gt; Flows make it easier to handle data that updates over time without writing complex callback code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Efficient &amp;amp; Reactive:&lt;/strong&gt; They only do work when needed, saving resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built for Coroutines:&lt;/strong&gt; Since Flows are part of Kotlin’s coroutine library, they play well with other coroutine features like launch and async.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flows in Android: Some Practical Examples
&lt;/h2&gt;

&lt;p&gt;Imagine you want to fetch and display a list of items from a database that updates in real time. Here’s how you might use a Flow:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Fake Database with a method to return a Flow of items.&lt;/li&gt;
&lt;li&gt;Use a Repository to provide the data from the fake database.&lt;/li&gt;
&lt;li&gt;Collect the data in your ViewModel and expose it as a StateFlow or LiveData.&lt;/li&gt;
&lt;li&gt;Observe the data in the Activity/Fragment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Fake Database
object FakeDatabase {
    // Simulate fetching a list of items from a database
    fun getItems(): Flow&amp;lt;List&amp;lt;String&amp;gt;&amp;gt; = flow {
        emit(emptyList()) // Emit an empty list initially
        delay(1000) // Simulate a delay for fetching data
        emit(listOf("Item 1", "Item 2", "Item 3", "Item 4")) // Emit the actual list
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Repository Implementation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class FakeRepository {
    // Fetch items from the fake database
    fun fetchItems(): Flow&amp;lt;List&amp;lt;String&amp;gt;&amp;gt; = FakeDatabase.getItems()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ViewModel Implementation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ItemViewModel : ViewModel() {
    private val repository = FakeRepository()

    // StateFlow to hold the list of items
    private val _items = MutableStateFlow&amp;lt;List&amp;lt;String&amp;gt;&amp;gt;(emptyList())
    val items: StateFlow&amp;lt;List&amp;lt;String&amp;gt;&amp;gt; get() = _items

    init {
        fetchItems()
    }

    private fun fetchItems() {
        viewModelScope.launch {
            repository.fetchItems().collectLatest { fetchedItems -&amp;gt;
                _items.value = fetchedItems
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Activity/Fragment Implementation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MainActivity : AppCompatActivity() {

    private val viewModel: ItemViewModel by viewModels()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Collect items and update the RecyclerView adapter
        lifecycleScope.launch {
            viewModel.items.collectLatest { items -&amp;gt;
                Log.d("LOG_TAG","Data from Database: $items")
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key Points in This Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fake Database:&lt;/strong&gt; Provides data using a Flow. Simulates asynchronous fetching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repository:&lt;/strong&gt; Acts as a bridge between the database and ViewModel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ViewModel:&lt;/strong&gt; Uses a StateFlow to expose the fetched data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activity/Fragment:&lt;/strong&gt; Collects the StateFlow and print it on logcat&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monitor network connection Using Flows
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use ConnectivityManager to monitor the network connection.&lt;/li&gt;
&lt;li&gt;Create a Flow to emit connection status updates.&lt;/li&gt;
&lt;li&gt;Collect the Flow in your activity or fragment and show the toast accordingly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Code Implementation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create a Flow to emit internet connectivity status
    fun observeNetworkStatus(context: Context): Flow&amp;lt;Boolean&amp;gt; = callbackFlow {
        val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

        val networkCallback = object : ConnectivityManager.NetworkCallback() {
            override fun onAvailable(network: Network) {
                trySend(true) // Emit 'true' when connected
            }

            override fun onLost(network: Network) {
                trySend(false) // Emit 'false' when disconnected
            }
        }

        // Register network callback
        if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.N) {
            connectivityManager.registerDefaultNetworkCallback(networkCallback)
        } else {
            val networkRequest = android.net.NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                .build()
            connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
        }

        awaitClose {
            // Unregister callback when Flow collection is canceled
            connectivityManager.unregisterNetworkCallback(networkCallback)
        }
    }.distinctUntilChanged(
Usage in an Activity or Fragment:

// Observe network status and show toast
        lifecycleScope.launch {
            observeNetworkStatus(this@MainActivity).collectLatest { isConnected -&amp;gt;
                val message = if (isConnected) {
                    "Internet Connected"
                } else {
                    "Internet Disconnected"
                }
                Toast.makeText(this@MainActivity, message, Toast.LENGTH_SHORT).show()
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Kotlin Flows make managing asynchronous data streams a breeze. They simplify your code, eliminate callback hell, and make your apps more reactive. Whether you’re handling user interactions or real-time updates, Flows are a go-to solution for modern Android development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start exploring Flows today and take your Android apps to the next level!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>androiddev</category>
      <category>flows</category>
    </item>
    <item>
      <title>Getting Started with Coroutines in Android Kotlin: Asynchronous Programming in Android</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Tue, 03 Dec 2024 17:11:23 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/getting-started-with-coroutines-in-android-kotlin-asynchronous-programming-in-android-2lio</link>
      <guid>https://dev.to/ahsanahmed03/getting-started-with-coroutines-in-android-kotlin-asynchronous-programming-in-android-2lio</guid>
      <description>&lt;p&gt;When building Android apps, you’ll often need to perform tasks like fetching data from a server, accessing a database, or processing files. These tasks can take time and, if not handled properly, may cause your app to freeze. Enter Kotlin Coroutines: a powerful tool that simplifies asynchronous programming while keeping your app smooth and responsive.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Coroutines?
&lt;/h2&gt;

&lt;p&gt;Coroutines are Kotlin’s way of handling asynchronous tasks in a structured and simple manner. Think of them as lightweight threads that let you perform long-running tasks like downloading files or fetching data without blocking the main thread.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Coroutines in Android?
&lt;/h2&gt;

&lt;p&gt;Avoid Freezing the UI: Coroutines let you offload long-running tasks to a background thread, keeping the app’s user interface smooth and responsive.&lt;br&gt;
Simpler Code: No more messy callbacks or complex threading logic. Coroutines allow you to write asynchronous code sequentially, making it easy to read and maintain.&lt;br&gt;
Lightweight: Unlike traditional threads, coroutines are very efficient and lightweight. You can run thousands of coroutines without straining system resources.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started with Coroutines
&lt;/h2&gt;

&lt;p&gt;Basic Coroutine Example&lt;br&gt;
Here’s how you can launch a coroutine to perform a task in the background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fun main() = runBlocking { // Start a coroutine scope
    launch { // Launch a coroutine
        delay(1000L) // Simulate a background task (1-second delay)
        println("Task completed!")
    }
    println("Hello, coroutines!")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, coroutines!
Task completed! (after 1 second)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using Coroutines in Android
&lt;/h2&gt;

&lt;p&gt;In Android, coroutines are often used with ViewModel, Room, or network calls. Here’s how to use coroutines in an Android project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Launching Coroutines in the ViewModel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the viewModelScope to launch coroutines tied to the lifecycle of a ViewModel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyViewModel : ViewModel() {

    fun fetchData() {
        viewModelScope.launch { // Launch coroutine tied to ViewModel
            delay(2000L) // Simulate network call
            println("Data fetched!")
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Making Network Requests with Coroutines&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can perform network operations using libraries like Retrofit with coroutines:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retrofit Service:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface ApiService {
    @GET("data")
    suspend fun fetchData(): List&amp;lt;String&amp;gt; // `suspend` makes it coroutine-friendly
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ViewModel Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyViewModel(private val apiService: ApiService) : ViewModel() {

    fun fetchApiData() {
        viewModelScope.launch {
            try {
                val data = apiService.fetchData() // Call API
                println("Received data: $data")
            } catch (e: Exception) {
                println("Error: ${e.message}")
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Coroutine Builders
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;launch&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Launches a coroutine that doesn’t return a result.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Example: Background tasks like database updates.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;async&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launches a coroutine that returns a result using await().&lt;/li&gt;
&lt;li&gt;Example: Fetching data from multiple APIs in parallel.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;runBlocking&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blocks the thread until the coroutine completes (used mainly for testing).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Coroutine Scopes in Android
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GlobalScope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For long-running application-wide tasks (use cautiously).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;viewModelScope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ideal for launching coroutines in a ViewModel.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;lifecycleScope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For launching coroutines in an Activity or Fragment tied to their lifecycle.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practical Example: Room Database + Coroutines
&lt;/h2&gt;

&lt;p&gt;Here’s how you can use coroutines with Room to fetch data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Dao
interface UserDao {
    @Query("SELECT * FROM users")
    suspend fun getUsers(): List&amp;lt;User&amp;gt; // Coroutine-friendly
}

class UserRepository(private val userDao: UserDao) {
    suspend fun fetchUsers() = userDao.getUsers()
}

class MyViewModel(private val repository: UserRepository) : ViewModel() {
    fun loadUsers() {
        viewModelScope.launch {
            val users = repository.fetchUsers()
            println("Loaded users: $users")
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Kotlin Coroutines are a game-changer for Android development. They make asynchronous programming easy to understand and maintain, ensuring that your app remains responsive. With the ability to handle background tasks seamlessly, coroutines are an essential tool for every Android developer.&lt;/p&gt;

&lt;p&gt;Start using coroutines today, and make your code cleaner, faster, and more efficient!&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>coroutines</category>
      <category>androiddev</category>
      <category>android</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>Create Responsive UI in Android Studio using SDP &amp; SSP</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Tue, 03 Dec 2024 15:43:36 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/create-responsive-ui-in-android-studio-using-sdp-ssp-4pll</link>
      <guid>https://dev.to/ahsanahmed03/create-responsive-ui-in-android-studio-using-sdp-ssp-4pll</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/_Mo0cT9kBzk"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Creating a responsive UI is essential for Android apps to look good on devices with different screen sizes. Hardcoding dimensions and text sizes using dp and sp can lead to inconsistencies. This is where SDP (Scalable DP) and SSP (Scalable SP) come to the rescue! These libraries ensure that your app adapts gracefully to various screen sizes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are SDP and SSP?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SDP (Scalable DP):&lt;/strong&gt; A library that scales your layout dimensions (like width, height, margins, or paddings) automatically based on the screen size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSP (Scalable SP):&lt;/strong&gt; Similar to SDP, but specifically for text sizes. It ensures text remains legible across devices without looking too big or small.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use SDP and SSP?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Consistency:&lt;/strong&gt; Ensures your app looks uniform across small, medium, and large devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ease of Use:&lt;/strong&gt; Removes the need to create multiple layout files for different screen sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Automatically adjusts dimensions and text sizes for various screen densities.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use SDP and SSP in Your Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Add the Dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, you need to add the SDP and SSP libraries to your project.&lt;/li&gt;
&lt;li&gt;Open the build.gradle file for your app module.&lt;/li&gt;
&lt;li&gt;Add the following dependencies:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;implementation ("com.intuit.sdp:sdp-android:1.1.1")&lt;br&gt;
 implementation ("com.intuit.ssp:ssp-android:1.1.1")&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click &lt;strong&gt;Sync Now&lt;/strong&gt; to download the libraries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Use SDP for Dimensions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of hardcoding &lt;code&gt;dp&lt;/code&gt; values in your XML layout, use SDP values like &lt;code&gt;@dimen/_16sdp&lt;/code&gt;. The SDP library provides pre-defined values that scale automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;TextView&lt;br&gt;
    android:layout_width="wrap_content"&lt;br&gt;
    android:layout_height="wrap_content"&lt;br&gt;
    android:text="Welcome!"&lt;br&gt;
    android:textSize="@dimen/_16ssp"&lt;br&gt;
    android:textColor="@color/black" /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, the text size adjusts automatically while maintaining proportionality with other elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Test Your Layout&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the Preview panel in Android Studio.&lt;/li&gt;
&lt;li&gt;Use the device size switcher (top bar in the design view) to simulate different screen sizes and densities.&lt;/li&gt;
&lt;li&gt;Ensure all elements scale properly without overlapping or cutting off.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Tips for Best Results
&lt;/h2&gt;

&lt;p&gt;Always combine SDP and SSP with ConstraintLayout or LinearLayout for better alignment and scaling.&lt;br&gt;
Avoid fixed sizes (e.g., &lt;code&gt;match_parent&lt;/code&gt;or &lt;code&gt;wrap_content&lt;/code&gt;) when SDP or SSP can handle it.&lt;br&gt;
Use tools attributes in your layouts to preview different text and dimension sizes without running the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Using SDP and SSP is a simple yet powerful way to create a responsive UI in Android. By following the steps above, you can ensure your app looks great on any screen size — no more messy layouts or unreadable text!&lt;/p&gt;

&lt;p&gt;Give SDP and SSP a try in your next project and see the difference it makes. Happy coding! 😊&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>ui</category>
      <category>androiddev</category>
      <category>kotlin</category>
      <category>android</category>
    </item>
    <item>
      <title>Implementing Firebase Cloud Messaging (FCM) in Android Studio with Kotlin | Step-by-Step Tutorial</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Fri, 12 Apr 2024 18:45:12 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/implementing-firebase-cloud-messaging-fcm-in-android-studio-with-kotlin-step-by-step-tutorial-5dh7</link>
      <guid>https://dev.to/ahsanahmed03/implementing-firebase-cloud-messaging-fcm-in-android-studio-with-kotlin-step-by-step-tutorial-5dh7</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/Ywn5FwTQwOU"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Welcome to this tutorial where we'll explore the powerful capabilities of Firebase Cloud Messaging (FCM) in Android Studio using Kotlin. FCM enables you to send and receive push notifications effortlessly in your app. From setting up Firebase in your project to implementing FCM messaging, this tutorial covers everything you need to know to leverage the full potential of Firebase in your Android app development journey.&lt;/p&gt;

&lt;p&gt;Step 1: Setting Up Firebase in Your Project&lt;br&gt;
Firstly, we'll guide you through the process of setting up Firebase in your Android Studio project. You'll learn how to create a Firebase project, add your app to the Firebase project, and configure the necessary dependencies.&lt;/p&gt;

&lt;p&gt;Step 2: Configuring FCM in Firebase Console&lt;br&gt;
Next, we'll show you how to configure Firebase Cloud Messaging in the Firebase console. You'll understand how to generate and retrieve the necessary credentials for integrating FCM into your app.&lt;/p&gt;

&lt;p&gt;Step 3: Integrating FCM into Your App&lt;br&gt;
In this step, we'll dive into the implementation details of integrating FCM into your Android app using Kotlin. You'll learn how to handle device registration, receive FCM messages, and process them to display push notifications.&lt;/p&gt;

&lt;p&gt;Step 4: Sending Push Notifications from Firebase Console&lt;br&gt;
We'll demonstrate how to send push notifications from the Firebase console to your app using FCM. You'll understand the various options available for targeting specific devices and user segments with personalized notifications.&lt;/p&gt;

&lt;p&gt;Step 5: Testing and Debugging FCM Integration&lt;br&gt;
Finally, we'll cover testing and debugging techniques to ensure the seamless integration of FCM into your app. You'll learn how to verify the delivery of push notifications and troubleshoot common issues.&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;br&gt;
Congratulations! You've successfully learned how to implement Firebase Cloud Messaging (FCM) in Android Studio using Kotlin. This tutorial has equipped you with the knowledge and skills to leverage FCM for sending and receiving push notifications in your Android app. We hope you found this tutorial helpful in enhancing your app's engagement and user experience.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, please feel free to leave them below. Don't forget to subscribe to our channel for more tutorials on Android app development with Kotlin and Firebase integration.&lt;/p&gt;

&lt;p&gt;Now, armed with the capabilities of Firebase Cloud Messaging, you're ready to enhance communication with your app users through timely and relevant push notifications. Happy coding!&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>android</category>
      <category>kotlin</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Implementing Google AdMob Interstitial Ads in Android Studio with Java | Step-by-Step Tutorial</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Tue, 09 Apr 2024 18:18:14 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/implementing-google-admob-interstitial-ads-in-android-studio-with-java-step-by-step-tutorial-2kf6</link>
      <guid>https://dev.to/ahsanahmed03/implementing-google-admob-interstitial-ads-in-android-studio-with-java-step-by-step-tutorial-2kf6</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/9ngjd4FJtc0"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Welcome to this detailed guide on implementing Google AdMob Interstitial Ads in Android Studio using Java. This tutorial covers the entire process, from loading Interstitial ads to displaying them in your app. Whether you're a seasoned developer or just beginning your app monetization journey, this video provides essential insights into maximizing your earnings through AdMob Interstitial ads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up Google AdMob Account and Creating Ad Units&lt;/strong&gt;&lt;br&gt;
To start, we'll guide you through the process of setting up a Google AdMob account and creating Interstitial ad units. You'll learn how to configure ad units to match the requirements of your app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Adding Google AdMob Dependency to Your Project&lt;/strong&gt;&lt;br&gt;
Next, we'll demonstrate how to add the Google AdMob dependency to your Android Studio project using Java. You'll understand the importance of integrating the AdMob SDK for seamless ad functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Loading Interstitial Ads&lt;/strong&gt;&lt;br&gt;
In this step, we'll cover how to load Interstitial ads into your app. You'll learn the necessary code implementation to fetch ads from the AdMob network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Displaying Interstitial Ads&lt;/strong&gt;&lt;br&gt;
We'll guide you through the process of displaying Interstitial ads at appropriate moments within your app. You'll understand how to trigger ad display events and ensure a smooth user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Maximizing Revenue and User Experience&lt;/strong&gt;&lt;br&gt;
In this final step, we'll discuss strategies for maximizing revenue while maintaining a positive user experience. You'll gain insights into ad placement, frequency, and other best practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Congratulations! You've successfully learned how to implement Google AdMob Interstitial Ads in Android Studio using Java. This tutorial has equipped you with practical insights to monetize your app effectively and maximize earnings through AdMob Interstitial ads.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, please feel free to leave them below. Don't forget to subscribe to our YouTube channel for more exciting tutorials on Android app development and monetization strategies.&lt;/p&gt;

&lt;p&gt;Now, armed with the knowledge of Google AdMob Interstitial ads implementation, you're ready to boost your app's revenue and provide users with a seamless ad experience. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="https://github.com/AhsanAhmed03/AdMob-Ads-Java" rel="noopener noreferrer"&gt;https://github.com/AhsanAhmed03/AdMob-Ads-Java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>admob</category>
      <category>interstitalads</category>
      <category>android</category>
      <category>java</category>
    </item>
    <item>
      <title>Implementing Google AdMob Banner Ads in Android Studio with Java | Easy Step-by-Step Guide</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Sun, 28 Jan 2024 08:38:19 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/implementing-google-admob-banner-ads-in-android-studio-with-java-easy-step-by-step-guide-3b6</link>
      <guid>https://dev.to/ahsanahmed03/implementing-google-admob-banner-ads-in-android-studio-with-java-easy-step-by-step-guide-3b6</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/IPxxGa84Pw0"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Welcome to this step-by-step tutorial where we'll dive into the world of app monetization. In this video, you'll learn how to implement Google AdMob Banner Ads in Android Studio using Java. We'll cover the integration of three distinct banner ad sizes—Simple Banner Ad, Medium Rectangle Banner Ad, and Large Banner Ad. Whether you're a seasoned developer or just starting with app monetization, this tutorial offers valuable insights into maximizing revenue through AdMob ads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up Google AdMob Account and Creating Ad Units&lt;/strong&gt;&lt;br&gt;
To begin, we'll guide you through the process of setting up a Google AdMob account and creating ad units. You'll learn how to configure different banner ad sizes to suit your app's layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Adding Google AdMob Dependency to Your Project&lt;/strong&gt;&lt;br&gt;
In this step, we'll demonstrate how to add the Google AdMob dependency to your Android Studio project using Java. You'll understand the importance of integrating the AdMob SDK for seamless ad functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Implementing Simple Banner Ads&lt;/strong&gt;&lt;br&gt;
Next, we'll guide you through the implementation of simple banner ads. You'll learn how to seamlessly integrate banner ads into your app's layout, providing a non-intrusive monetization strategy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Implementing Medium Rectangle and Large Banner Ads&lt;/strong&gt;&lt;br&gt;
We'll cover the implementation of medium rectangle and large banner ads, offering you flexibility in choosing ad formats that complement your app's design and layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Maximizing Revenue and User Experience&lt;/strong&gt;&lt;br&gt;
In this step, we'll discuss strategies for maximizing revenue while ensuring a positive user experience. You'll gain insights into ad placement, frequency, and other best practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Congratulations! You've successfully learned how to implement Google AdMob banner ads in Android Studio using Java. This tutorial has equipped you with practical insights to monetize your app effectively and enhance user engagement through well-integrated ads.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, please feel free to leave them below. Don't forget to subscribe to our YouTube channel for more exciting tutorials on Android app development and monetization strategies.&lt;/p&gt;

&lt;p&gt;Now, armed with the knowledge of Google AdMob implementation, you're ready to boost your app's revenue and provide users with a seamless ad experience. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build android apps without coding&lt;/strong&gt; &lt;br&gt;
Start for free: &lt;a href="https://try.draftbit.com/buildwithoutcode" rel="noopener noreferrer"&gt;https://try.draftbit.com/buildwithoutcode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="https://github.com/AhsanAhmed03/AdMob-Ads-Java" rel="noopener noreferrer"&gt;https://github.com/AhsanAhmed03/AdMob-Ads-Java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>admo</category>
      <category>android</category>
      <category>monetization</category>
      <category>java</category>
    </item>
    <item>
      <title>Implementing Google AdMob Banner Ads with Shimmer Effect in Android Studio using Kotlin | Step-by-Step Guide</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Fri, 12 Jan 2024 17:39:02 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/implementing-google-admob-banner-ads-with-shimmer-effect-in-android-studio-using-kotlin-step-by-step-guide-4k21</link>
      <guid>https://dev.to/ahsanahmed03/implementing-google-admob-banner-ads-with-shimmer-effect-in-android-studio-using-kotlin-step-by-step-guide-4k21</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/uRMogMqoBNQ"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Welcome to this tutorial where you'll learn how to seamlessly integrate different types of banner ads from Google AdMob into your Android Studio project using Kotlin. We'll cover the implementation of simple banner ads, medium rectangle banner ads, and large banner ads, providing you with a comprehensive guide to monetizing your app. Whether you're a developer exploring ad integration or aiming to enhance your app's revenue, this video offers practical insights for successful Google AdMob implementation in Kotlin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up Google AdMob Account&lt;/strong&gt;&lt;br&gt;
To start, we'll guide you through the process of setting up a Google AdMob account and creating ad units. You'll learn how to configure different types of banner ads to suit your app's layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Adding Google AdMob Dependency to Your Project&lt;/strong&gt;&lt;br&gt;
In this step, we'll demonstrate how to add the Google AdMob dependency to your Android Studio project using Kotlin. You'll understand the importance of integrating the AdMob SDK for ad functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Implementing Simple Banner Ads&lt;/strong&gt;&lt;br&gt;
Next, we'll guide you through the implementation of simple banner ads. You'll learn how to integrate banner ads seamlessly into your app's layout, enhancing the overall user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Adding Shimmer Effect to Banner Ads&lt;/strong&gt;&lt;br&gt;
In this step, we'll explore how to add a shimmer effect to your banner ads, creating an eye-catching and engaging visual experience for users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Implementing Medium Rectangle and Large Banner Ads&lt;/strong&gt;&lt;br&gt;
We'll cover the implementation of medium rectangle and large banner ads, providing you with the flexibility to choose ad formats that best suit your app's design and layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Congratulations! You've successfully learned how to implement Google AdMob banner ads with a shimmer effect in Android Studio using Kotlin. This tutorial has equipped you with practical insights to monetize your app and enhance user engagement through well-integrated ads.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, please feel free to leave them below. Don't forget to subscribe to our YouTube channel for more exciting tutorials on Android app development and monetization strategies.&lt;/p&gt;

&lt;p&gt;Now, armed with the knowledge of Google AdMob implementation, you're ready to boost your app's revenue and provide users with a visually appealing ad experience. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt;&lt;a href="https://github.com/AhsanAhmed03/AdMob-Ads" rel="noopener noreferrer"&gt;https://github.com/AhsanAhmed03/AdMob-Ads&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>admob</category>
      <category>ads</category>
      <category>android</category>
      <category>shimmer</category>
    </item>
    <item>
      <title>How to Upload and Push Android Studio Projects to GitHub | Step-by-Step Guide</title>
      <dc:creator>AhsanAhmed03</dc:creator>
      <pubDate>Thu, 28 Dec 2023 17:41:07 +0000</pubDate>
      <link>https://dev.to/ahsanahmed03/how-to-upload-and-push-android-studio-projects-to-github-step-by-step-guide-3b3m</link>
      <guid>https://dev.to/ahsanahmed03/how-to-upload-and-push-android-studio-projects-to-github-step-by-step-guide-3b3m</guid>
      <description>&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/CK9JH70E6xo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Welcome to this step-by-step tutorial where you'll explore the straightforward process of uploading your Android Studio projects to GitHub. From initializing a repository to pushing your code to the cloud, you'll gain practical insights to streamline project collaboration and version control. Whether you're a seasoned developer or just getting started, this video provides essential knowledge for integrating GitHub into your Android Studio workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Initializing a Repository on GitHub&lt;/strong&gt;&lt;br&gt;
To start, we'll guide you through the process of initializing a new repository on GitHub. You'll learn how to set up the repository with a README file and choose options that suit your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Configuring Git in Android Studio&lt;/strong&gt;&lt;br&gt;
In this step, we'll walk you through configuring Git in Android Studio. You'll set up your Git username and email, ensuring that your contributions are properly attributed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Creating a Local Git Repository&lt;/strong&gt;&lt;br&gt;
Next, we'll explore how to create a local Git repository within your Android Studio project. You'll learn the necessary Git commands to initialize the repository and establish a connection with the GitHub repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Adding, Committing, and Pushing Code&lt;/strong&gt;&lt;br&gt;
We'll guide you through the process of adding, committing, and pushing your code to GitHub. You'll understand the importance of committing changes with meaningful messages and pushing them to the remote repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Verifying Changes on GitHub&lt;/strong&gt;&lt;br&gt;
In this step, you'll verify that your code changes have been successfully pushed to GitHub. We'll explore the GitHub repository to ensure that the project is up to date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Congratulations! You've successfully learned how to upload and push Android Studio projects to GitHub. This tutorial has equipped you with practical insights to streamline your project collaboration and version control using GitHub.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, please feel free to leave them below. Don't forget to subscribe to our YouTube channel for more exciting tutorials on Android app development and GitHub collaboration.&lt;/p&gt;

&lt;p&gt;Now, armed with the knowledge of uploading and pushing projects to GitHub, you're ready to efficiently collaborate, contribute, and maintain version control in your Android Studio projects. Happy coding!&lt;/p&gt;

&lt;p&gt;Feel free to reach out to me with any questions or opportunities at (&lt;a href="mailto:aahsanaahmed26@gmail.com"&gt;aahsanaahmed26@gmail.com&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt; (&lt;a href="https://www.linkedin.com/in/ahsan-ahmed-39544b246/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/ahsan-ahmed-39544b246/&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Facebook&lt;/strong&gt; (&lt;a href="https://www.facebook.com/profile.php?id=100083917520174" rel="noopener noreferrer"&gt;https://www.facebook.com/profile.php?id=100083917520174&lt;/a&gt;).&lt;br&gt;
&lt;strong&gt;YouTube&lt;/strong&gt; (&lt;a href="https://www.youtube.com/@mobileappdevelopment4343" rel="noopener noreferrer"&gt;https://www.youtube.com/@mobileappdevelopment4343&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;Instagram&lt;/strong&gt; (&lt;a href="https://www.instagram.com/ahsanahmed_03/" rel="noopener noreferrer"&gt;https://www.instagram.com/ahsanahmed_03/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>github</category>
      <category>android</category>
      <category>androidstudio</category>
      <category>howto</category>
    </item>
  </channel>
</rss>
