<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Patryk Kosieradzki on Medium]]></title>
        <description><![CDATA[Stories by Patryk Kosieradzki on Medium]]></description>
        <link>https://medium.com/@patrykkosieradzki?source=rss-1419cf36418------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_cM003t7AEDeCwJ9Rs_LoQ@2x.jpeg</url>
            <title>Stories by Patryk Kosieradzki on Medium</title>
            <link>https://medium.com/@patrykkosieradzki?source=rss-1419cf36418------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 06:06:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patrykkosieradzki/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Fix Keyboard Issues Introduced in the Latest Jetpack Compose (1.4.0)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/better-programming/how-to-fix-keyboard-issues-introduced-in-the-latest-jetpack-compose-1-4-0-c37f280552e9?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2048/0*0knRElWeiGOFJj2A" width="2048"></a></p><p class="medium-feed-snippet">Overcoming the issue that I encountered</p><p class="medium-feed-link"><a href="https://medium.com/better-programming/how-to-fix-keyboard-issues-introduced-in-the-latest-jetpack-compose-1-4-0-c37f280552e9?source=rss-1419cf36418------2">Continue reading on Better Programming »</a></p></div>]]></description>
            <link>https://medium.com/better-programming/how-to-fix-keyboard-issues-introduced-in-the-latest-jetpack-compose-1-4-0-c37f280552e9?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/c37f280552e9</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Fri, 31 Mar 2023 16:20:50 GMT</pubDate>
            <atom:updated>2023-04-01T05:34:47.534Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Top 10 Mobile App Security Risks #1 — Improper Platform Usage on Android]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/top-10-mobile-app-security-risks-1-improper-platform-usage-on-android-50e28097661e?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2600/0*BCbQcT1jqUHdtqAv" width="4032"></a></p><p class="medium-feed-snippet">The first article in a series dedicated to the OWASP Mobile Top 10&#x200A;&#x2014;&#x200A;a comprehensive list of the most common and significant security&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/codex/top-10-mobile-app-security-risks-1-improper-platform-usage-on-android-50e28097661e?source=rss-1419cf36418------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/top-10-mobile-app-security-risks-1-improper-platform-usage-on-android-50e28097661e?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/50e28097661e</guid>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Fri, 24 Mar 2023 10:04:07 GMT</pubDate>
            <atom:updated>2023-04-12T11:03:54.416Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Mastering Android Dialogs: Don’t follow official Google Guides]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/mastering-android-dialogs-dont-follow-official-google-guides-3821f8e9dd91?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2600/0*ol3EUfYUbGXmWLpU" width="7669"></a></p><p class="medium-feed-snippet">This article is part of a multi-series on Mastering Android Dialogs</p><p class="medium-feed-link"><a href="https://medium.com/codex/mastering-android-dialogs-dont-follow-official-google-guides-3821f8e9dd91?source=rss-1419cf36418------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/mastering-android-dialogs-dont-follow-official-google-guides-3821f8e9dd91?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/3821f8e9dd91</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 09:48:11 GMT</pubDate>
            <atom:updated>2022-11-07T13:35:16.399Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Dagger/Hilt vs. Koin for Jetpack Compose Apps]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/better-programming/dagger-hilt-vs-koin-dependency-injection-for-jetpack-compose-apps-2e598f00aff?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2600/0*_wG6vKAMYjwj3yX7" width="5184"></a></p><p class="medium-feed-snippet">Advantages and disadvantages of Dagger and&#xA0;Koin</p><p class="medium-feed-link"><a href="https://medium.com/better-programming/dagger-hilt-vs-koin-dependency-injection-for-jetpack-compose-apps-2e598f00aff?source=rss-1419cf36418------2">Continue reading on Better Programming »</a></p></div>]]></description>
            <link>https://medium.com/better-programming/dagger-hilt-vs-koin-dependency-injection-for-jetpack-compose-apps-2e598f00aff?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e598f00aff</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sun, 13 Mar 2022 21:41:47 GMT</pubDate>
            <atom:updated>2022-11-06T14:06:10.580Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Why Using Navigation-Compose in Your Jetpack Compose App is a Bad Idea]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/better-programming/why-using-navigation-compose-in-your-jetpack-compose-app-is-a-bad-idea-2b16e8751d89?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2600/0*p0AsCwW8vfrxGui4" width="3999"></a></p><p class="medium-feed-snippet">Know the pitfalls of Navigation Compose</p><p class="medium-feed-link"><a href="https://medium.com/better-programming/why-using-navigation-compose-in-your-jetpack-compose-app-is-a-bad-idea-2b16e8751d89?source=rss-1419cf36418------2">Continue reading on Better Programming »</a></p></div>]]></description>
            <link>https://medium.com/better-programming/why-using-navigation-compose-in-your-jetpack-compose-app-is-a-bad-idea-2b16e8751d89?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b16e8751d89</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack-navigation]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sat, 12 Feb 2022 23:26:47 GMT</pubDate>
            <atom:updated>2022-11-06T14:02:38.993Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to make Jetpack Compose navigation easier and testable]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://proandroiddev.com/how-to-make-jetpack-compose-navigation-easier-and-testable-b4b19fd5f2e4?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2600/0*uaKL3XmDemSjoxFL" width="5575"></a></p><p class="medium-feed-snippet">Navigating in Compose is easy</p><p class="medium-feed-link"><a href="https://proandroiddev.com/how-to-make-jetpack-compose-navigation-easier-and-testable-b4b19fd5f2e4?source=rss-1419cf36418------2">Continue reading on ProAndroidDev »</a></p></div>]]></description>
            <link>https://proandroiddev.com/how-to-make-jetpack-compose-navigation-easier-and-testable-b4b19fd5f2e4?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4b19fd5f2e4</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 16:32:44 GMT</pubDate>
            <atom:updated>2022-11-01T20:03:20.069Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Make sure to update your StateFlow safely in Kotlin!]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://proandroiddev.com/make-sure-to-update-your-stateflow-safely-in-kotlin-9ad023db12ba?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/2600/0*ZuNmYBF_u4rO0mcn" width="6000"></a></p><p class="medium-feed-snippet">Hi, today I come to you with a quick tip on how to update your StateFlows safely in Kotlin.</p><p class="medium-feed-link"><a href="https://proandroiddev.com/make-sure-to-update-your-stateflow-safely-in-kotlin-9ad023db12ba?source=rss-1419cf36418------2">Continue reading on ProAndroidDev »</a></p></div>]]></description>
            <link>https://proandroiddev.com/make-sure-to-update-your-stateflow-safely-in-kotlin-9ad023db12ba?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ad023db12ba</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sun, 25 Jul 2021 15:57:19 GMT</pubDate>
            <atom:updated>2022-11-01T20:03:56.642Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[LiveData vs SharedFlow and StateFlow in MVVM and MVI Architecture]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://proandroiddev.com/livedata-vs-sharedflow-and-stateflow-in-mvvm-and-mvi-architecture-57aad108816d?source=rss-1419cf36418------2"><img src="https://cdn-images-1.medium.com/max/1024/1*xBCWY4rKovjRmP7C2McVCA.jpeg" width="1024"></a></p><p class="medium-feed-snippet">Last year kotlinx.coroutines library introduced two new Flow types, SharedFlow and StateFlow, which also have their mutable types &#x2014;&#x2026;</p><p class="medium-feed-link"><a href="https://proandroiddev.com/livedata-vs-sharedflow-and-stateflow-in-mvvm-and-mvi-architecture-57aad108816d?source=rss-1419cf36418------2">Continue reading on ProAndroidDev »</a></p></div>]]></description>
            <link>https://proandroiddev.com/livedata-vs-sharedflow-and-stateflow-in-mvvm-and-mvi-architecture-57aad108816d?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/57aad108816d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mvi]]></category>
            <category><![CDATA[android-architecture]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Wed, 14 Jul 2021 21:41:17 GMT</pubDate>
            <atom:updated>2022-11-01T20:05:48.545Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Android ListView VS. RecyclerView]]></title>
            <link>https://patrykkosieradzki.medium.com/android-listview-vs-recyclerview-95f52808e039?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/95f52808e039</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[listview]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[diffutil]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sun, 30 May 2021 23:16:15 GMT</pubDate>
            <atom:updated>2022-11-01T20:07:26.132Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WM1ZEIg9mEeWucQnSRcvkA.jpeg" /><figcaption><a href="https://www.teahub.io/">https://www.teahub.io/</a></figcaption></figure><p>Scrollable list is one of the most common feature in modern mobile apps. In Android we have two popular ways to achieve this. We can use either <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong> </a>or <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView</strong></a>. Do you know exactly how they work and which one should you choose for your projects? Maybe you’re struggling with understanding when to use each of them. Let me help you with that. This article is gonna cover all of these questions and even more!</p><p><strong>FUN FACT</strong></p><p><strong>ListView </strong>vs <strong>RecyclerView </strong>is one of the most common questions you can be asked at an Android Dev Interview, so it is worth to read this article and to test both of them on your own to check out what they can do</p><h3>One last thing before we start</h3><h4>✉️ Android Dev Newsletter</h4><p>If you enjoy learning about Android like I do and want to stay up to date with the latest, worth reading articles, programming news and much more, consider subscribing to my newsletter 👇<br><a href="https://androiddevnews.com/">https://androiddevnews.com/</a></p><h4>🎙 Android Talks Podcast</h4><p>If you’re a Polish speaker and want to listen to what I have to say about Android, architecture, security and other interesting topics, check out my podcast 👇<br><a href="https://androidtalks.buzzsprout.com/">https://androidtalks.buzzsprout.com/</a></p><h3>Availability</h3><p>The first key difference between the <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView </strong></a>and <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView </strong></a>is when where they introduced. Well, <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView </strong></a>has been with us since the very beginning (API 1). It was always a way for Android Developers to display scrollable lists. It wasn’t the best solution though, because the list had to create a new view item every time user scrolled and as you know view creation is a very expensive thing to do. The bigger the list, the more resource hungry would the application be. It was a pain in the a** for Android Developers before <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView</strong> </a>came out.</p><p><strong>NOTE</strong></p><p>You could implement <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder </strong></a>in the <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView </strong></a>and reuse the views like in <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView</strong></a>, but it was more like optional thing to do, while in <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView </strong></a>it’s the default way of writing the adapter class.</p><h4>Developer’s redemption</h4><p>In 2014, after a long time of waiting, <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView</strong></a>, <a href="https://developer.android.com/jetpack/androidx/releases/cardview"><strong>CardView </strong></a>and <strong>Design Support Library</strong> were introduced. The idea of <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView </strong></a>was very simple. Instead of creating a new view every time user scrolled to the next positions, just create views once and recycle/reuse them. This was achievable by using <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder</strong></a>. Besides that, there is also <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager"><strong>LayoutManager</strong></a>, <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemDecoration"><strong>ItemDecoration</strong></a>, <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator"><strong>ItemAnimator</strong> </a>and more. Let’s talk in more detail about them…</p><h3>So what’s RecyclerView exactly?</h3><p><a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView</strong> </a>is a library for list drawing that essentially provides a fixed-size window to load a large dataset into. When the views get out of scope it <strong>recycles</strong> the views created before. It is a standalone support library, so in order to use it in your project you have add it separately to your app module’s <strong>build.gradle</strong> file. As of 2021 it is a part of Jetpack, so all of the info about how to include it in your project can be found here: <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview">https://developer.android.com/jetpack/androidx/releases/recyclerview</a></p><h3>ViewHolder</h3><p>A <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder </strong></a>describes an item view and metadata about its place within the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong></a>. It allows making our list scroll smoothly by storing views references. That’s why it’s called a <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder</strong></a>. By doing this calling <a href="https://developer.android.com/reference/android/view/View#findViewById(int)"><strong>findViewById(int id)</strong></a><strong> </strong>occurs much less times, instead of calling it for the entire dataset on each view binding. It can be also implemented in <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong></a>, but it’s not mandatory. The <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView’s</strong> </a>adapter forces us to use the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder</strong> </a>pattern. The adapter actions are separated to creation — <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#createViewHolder(android.view.ViewGroup,%20int)"><strong>onCreateViewHolder(…)</strong></a> and to updating the view — <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,%20int)"><strong>onBindViewHolder(…)</strong></a>. If you implement the adapter for <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong> </a>then it is compulsory to provide a <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder</strong></a><strong>.</strong> In <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong> </a>it’s optional, but not using it causes inefficient scrolling and much higher memory usage.</p><h3>LayoutManager</h3><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager"><strong>LayoutManager</strong> </a>is responsible for laying out the row views. It allows us to choose how the views should be displayed and scrolled. Besides that it is telling the <strong>ViewHolder</strong> when to recycle a child view once it’s out of scope.</p><p>When using a <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong></a>, you can only create a vertical-scrolling list, so it’s not really a flexible solution for us. If you wanted to create a grid before <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView</strong></a> was introduced, you had to use another UI component for that — <a href="https://developer.android.com/reference/android/widget/GridView"><strong>GridView</strong></a>.</p><p>Now, that we have the <strong>RecyclerView</strong> everything is easier. There are 3 main <strong>LayoutManagers</strong> you can choose from:</p><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/LinearLayoutManager"><strong>LinearLayoutManager</strong></a> — handles vertical and horizontal linear layouts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*As_J0Sewkj76bpaF.png" /></figure><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/GridLayoutManager"><strong>GridLayoutManager</strong></a> — for managing grid layouts with columns/spans</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/0*UaTiIgVvjPAHTUs1.png" /></figure><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/StaggeredGridLayoutManager"><strong>StaggeredLayoutManager </strong></a>— for handling grids, but each item can have different size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/0*uSmrbbj0Df1e7tyF.png" /></figure><h3>Adapter</h3><p>The most important thing about the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong> </a>is the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter"><strong>Adapter</strong></a>. Like any other adapters it’s responsibility is to bind datasets to views that are going to be displayed in the window. A typical adapter is just an iterator that has <strong>getCount()</strong> method for knowing about limitations. Usually it depends on the dataset size to create new views for binding. This kind of adapters are also used in <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong> </a>or <a href="https://developer.android.com/reference/androidx/viewpager/widget/ViewPager"><strong>ViewPager</strong></a> for example.</p><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong></a>, as mentioned before, uses the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder </strong></a>pattern by default. In this case the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong> </a>adapter is not creating new views every time, but instead it creates only <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolders</strong> </a>that hold the inflated views to reuse them later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5275d6550e89c6d1098687ff7c27bfd9/href">https://medium.com/media/5275d6550e89c6d1098687ff7c27bfd9/href</a></iframe><p><strong>NOTE</strong></p><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolders</strong> </a>are created and referenced with specific item <strong>viewType (Int)</strong>, not the position. Because of that it is easier for the adapter to find views to reuse and you can add as many view types as you want, by creating new <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder"><strong>ViewHolder </strong></a>type classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc6f82c49dc4954eb330a3f83cac56f5/href">https://medium.com/media/bc6f82c49dc4954eb330a3f83cac56f5/href</a></iframe><p>The <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,%20int,%20java.util.List%3Cjava.lang.Object%3E)"><strong>onBindViewHolder(…)</strong></a> method is used to bind views every time a new list element will appear while scrolling, so it will be called a lot of times during scrolling the list, so make sure it is well written to avoid memory and performance issues (for example adding onClick events, interfaces, etc.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbf9d678a3f8a4a4d60faa2d6b2ce3f6/href">https://medium.com/media/bbf9d678a3f8a4a4d60faa2d6b2ce3f6/href</a></iframe><p>The last thing you have to take care about is the <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#getItemCount()"><strong>getItemCount()</strong> </a>method. This one will be called several times to know the size limit of the list. It generally returns size of the dataset that is used in the adapter.</p><h3>ItemDecoration</h3><p>An <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html"><strong>ItemDecoration </strong></a>allows the application to add a special drawing and layout offset to specific item views from the adapter’s data set. This can be useful for drawing dividers between items, highlights, visual grouping boundaries and more.</p><p>All <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html"><strong>ItemDecorations </strong></a>are drawn in the order they were added, before the item views (in <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemDecoration#onDraw(android.graphics.Canvas,%20androidx.recyclerview.widget.RecyclerView,%20androidx.recyclerview.widget.RecyclerView.State)"><strong>onDraw()</strong></a> and after the items (in <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemDecoration#onDrawOver(android.graphics.Canvas,%20androidx.recyclerview.widget.RecyclerView,%20androidx.recyclerview.widget.RecyclerView.State)"><strong>onDrawOver(Canvas, RecyclerView, RecyclerView.State)</strong></a>.</p><p>For example, if you want to add divider between <a href="https://developer.android.com/jetpack/androidx/releases/recyclerview"><strong>RecyclerView </strong></a>items, you can use <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html"><strong>ItemDecoration </strong></a>to achieve this – <a href="https://developer.android.com/reference/android/support/v7/widget/DividerItemDecoration.html"><strong>DividerItemDecoration</strong> </a>to be specific.</p><p><a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong> </a>does not support <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html"><strong>ItemDecoration</strong></a>, so you have to figure it out on your own.</p><h3>ItemAnimator</h3><p>This class defines the animations that take place on items as changes are made to the adapter. Subclasses of <strong>ItemAnimator </strong>can be used to implement custom animations for actions on <strong>ViewHolder </strong>items. The <strong>RecyclerView </strong>will manage retaining these items while they are being animated, but implementors must call <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator#dispatchAnimationFinished(androidx.recyclerview.widget.RecyclerView.ViewHolder)">dispatchAnimationFinished(ViewHolder)</a> when a ViewHolder’s animation is finished. In other words, there must be a matching <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator#dispatchAnimationFinished(androidx.recyclerview.widget.RecyclerView.ViewHolder)">dispatchAnimationFinished(ViewHolder)</a> call for each <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator#animateAppearance(androidx.recyclerview.widget.RecyclerView.ViewHolder,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo)">animateAppearance()</a>, <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator#animateChange(androidx.recyclerview.widget.RecyclerView.ViewHolder,%20androidx.recyclerview.widget.RecyclerView.ViewHolder,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo)">animateChange()</a> <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator#animatePersistence(androidx.recyclerview.widget.RecyclerView.ViewHolder,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo)">animatePersistence()</a>, and <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ItemAnimator#animateDisappearance(androidx.recyclerview.widget.RecyclerView.ViewHolder,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo,%20androidx.recyclerview.widget.RecyclerView.ItemAnimator.ItemHolderInfo)">animateDisappearance()</a> call.</p><p>By default, RecyclerView uses <a href="https://developer.android.com/reference/androidx/recyclerview/widget/DefaultItemAnimator">DefaultItemAnimator</a>.</p><p><a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong></a> does not support <strong>ItemAnimator</strong>, so in order to add some animations to it you have to create custom animations in <em>“anim”</em> folder and manually attach it to a specific views.</p><h3>Notifying Adapter</h3><p><a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong></a> has one method that you can call in order to tell the adapter (which extends <a href="https://developer.android.com/reference/android/widget/BaseAdapter"><strong>BaseAdapter</strong></a>) that some of the items changed. This is <a href="https://developer.android.com/reference/android/widget/BaseAdapter#notifyDataSetChanged()"><strong>notifyDataSetChanged()</strong></a>. As you can see, this is not very much for us developers. Shouldn’t there be more than just that?</p><p>YUP!</p><p>That’s why <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter"><strong>RecyclerView.Adapter</strong></a> now includes a lot of them, so you can have full control of your items. For example <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyDataSetChanged()">notifyDataSetChanged</a>(), <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int,%20java.lang.Object)">notifyItemChanged(int position)</a>, <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemInserted(int)">notifyItemInserted(int position)</a> any many more.. Be sure to test it out in different scenarios to fully understand it.</p><h3>Extras</h3><h4>DiffUtil.Callback</h4><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil"><strong>DiffUtil</strong></a> is a utility class that calculates the difference between two lists and outputs a list of update operations that converts the first list into the second one.</p><p>It can be used to calculate updates for a RecyclerView Adapter. See <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter">ListAdapter</a> and <a href="https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListDiffer">AsyncListDiffer</a> which can simplify the use of DiffUtil on a background thread.</p><p>DiffUtil uses Eugene W. Myers’s difference algorithm to calculate the minimal number of updates to convert one list into another. Myers’s algorithm does not handle items that are moved so DiffUtil runs a second pass on the result to detect items that were moved.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9796b60089ecd69803e98d2b800d0f09/href">https://medium.com/media/9796b60089ecd69803e98d2b800d0f09/href</a></iframe><p>The callback helps us to skip manual handling of notifying an adapter. Instead of using different methods for each type of notifications as notifyItemInserted(), notifyItemRemoved() or notifyItemChanged() we just can use this simple method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b5741a51962e44529ca120199dc049e/href">https://medium.com/media/1b5741a51962e44529ca120199dc049e/href</a></iframe><p>NOTE</p><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil"><strong>DiffUtil</strong></a>, <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter"><strong>ListAdapter</strong></a>, and <a href="https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListDiffer"><strong>AsyncListDiffer</strong></a><strong> </strong>require the list to not mutate while in use. This generally means that both the lists themselves and their elements (or at least, the properties of elements used in diffing) should not be modified directly. Instead, new lists should be provided any time content changes. It’s common for lists passed to <strong>DiffUtil </strong>to share elements that have not mutated, so it is not strictly required to reload all data to use <strong>DiffUtil</strong>.</p><h4>ListAdapter</h4><p><a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter">RecyclerView.Adapter</a> base class for presenting List data in a <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView">RecyclerView</a>, including computing diffs between Lists on a background thread.</p><p>This class is a convenience wrapper around <a href="https://developer.android.com/reference/androidx/recyclerview/widget/AsyncListDiffer">AsyncListDiffer</a> that implements Adapter common default behavior for item access and counting.</p><p>While using a LiveData&lt;List&gt; is an easy way to provide data to the adapter, it isn’t required — you can use <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List%3CT%3E)">submitList(List)</a> when new lists are available.</p><p>Here’s a quick example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd39da7de78d514dc6fb2b921a4b98a5/href">https://medium.com/media/fd39da7de78d514dc6fb2b921a4b98a5/href</a></iframe><p>As you can, we just need to define <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onCreateViewHolder(android.view.ViewGroup,%20int)"><strong>onCreateViewHolder</strong></a>, <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,%20int,%20java.util.List%3Cjava.lang.Object%3E)"><strong>onBindViewHolder</strong></a> and <a href="https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback"><strong>DiffUtil.ItemCallback</strong></a> (which is the simplest type of <a href="https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.Callback"><strong>DiffUtil.Callback</strong></a>) methods. From now on it is enough to use <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter#submitList(java.util.List%3CT%3E)"><strong>adapter.submitList(newItems)</strong></a> method of <a href="https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter"><strong>ListAdapter</strong></a> to update the data</p><h3>Summary</h3><p><a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView</strong></a> has been with us for a long time, but as you can see its deputy <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong></a><strong> </strong>is beyond <a href="https://developer.android.com/reference/android/widget/ListView"><strong>ListView’s</strong></a> capacity. It is more efficient by default, has simpler animations and adapter actions and overall using this new API is quite nice. So if you still wonder what should you choose for your lists in future apps — go for <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView"><strong>RecyclerView</strong></a>. I hope I helped with understanding the differences between these two. Be sure to test them out on your own and see how different mechanisms work</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95f52808e039" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy UI And Screenshot Testing On Android]]></title>
            <link>https://proandroiddev.com/easy-ui-and-screenshot-testing-on-android-2b138f6d1eb8?source=rss-1419cf36418------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b138f6d1eb8</guid>
            <category><![CDATA[android-testing]]></category>
            <category><![CDATA[screenshot-testing]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Patryk Kosieradzki]]></dc:creator>
            <pubDate>Sat, 01 May 2021 21:45:46 GMT</pubDate>
            <atom:updated>2022-11-01T20:08:18.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T8xCNPbhD9gEcQpvAK7pjQ.jpeg" /><figcaption><a href="https://www.teahub.io/">https://www.teahub.io/</a></figcaption></figure><h3>Ways of testing on Android</h3><p>Every good Android application should be well tested to minimize the risk of error after releasing it to the world. The most basic tests for any application are Unit Tests. You <strong>must</strong> write them to ensure that a particular part of the code is working.</p><p>On Android we have also Instrumentation Tests — tests that run on physical devices and emulators, and they can take advantage of the Android framework APIs and supporting APIs, such as AndroidX Test. One of many ways of using this mechanism is to test the UI and take screenshots of every screen in our app. I really like this, because if you run this UI/Screenshot Test every time before creating a new pull request, you can easily check if you didn’t change something in the UI by mistake.</p><h3>One last thing before we start</h3><h4>✉️ Android Dev Newsletter</h4><p>If you enjoy learning about Android like I do and want to stay up to date with the latest, worth reading articles, programming news and much more, consider subscribing to my newsletter 👇<br><a href="https://androiddevnews.com/">https://androiddevnews.com/</a></p><h4>🎙 Android Talks Podcast</h4><p>If you’re a Polish speaker and want to listen to what I have to say about Android, architecture, security and other interesting topics, check out my podcast 👇<br><a href="https://androidtalks.buzzsprout.com/">https://androidtalks.buzzsprout.com/</a></p><h3>How to capture device screenshots?</h3><p>I’ve worked on a few projects that used screenshot testing and these test were always dependent on external libraries like <a href="https://github.com/Karumi/Shot"><strong>Karumi Shot</strong></a> or <a href="https://github.com/facebook/screenshot-tests-for-android"><strong>Facebook Screenshot Tests For Android</strong></a>. These libraries were honestly a pain in the ass, completely impossible to set up and use in a long term. One guy from my project spent a few days to manually fix some code inside the library to make it work on Windows 10. I decided that this was too much for a simple operation like taking a device screenshot, so I began to research for a better solution.</p><h4>What did I find?</h4><p>Well, first of all, <strong>Android 4.3</strong> is a minimum system version we need to have in our project, because we are gonna be using <a href="https://developer.android.com/training/testing/ui-automator"><strong>UI Automator</strong></a> under the hood. The solution I found is simply… using <a href="https://developer.android.com/studio/test"><strong>Android Support Test Library</strong></a>. This library contains a <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/Screenshot"><strong>Screenshot</strong></a> class and <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/Screenshot.html#capture()"><strong>capture()</strong></a> method that we’re gonna need.</p><p><strong>This is great, because all of the screenshots can be taken, even if, for example, the Activity/Fragment is not currently displayed on the screen or a system dialog is in the foreground.</strong></p><p>As I said, we’re gonna need the <strong>Screenshot.capture()</strong> method:</p><p>Creates a <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/ScreenCapture.html"><strong>ScreenCapture</strong></a><strong> </strong>that contains a <a href="https://developer.android.com/reference/android/graphics/Bitmap.html"><strong>Bitmap</strong></a><strong> </strong>of the visible screen content for Build.VERSION_CODES.JELLY_BEAN_MR2 and above.</p><p>Note: Only use this method if all your tests run on API versions Build.VERSION_CODES.JELLY_BEAN_MR2 or above. If you need to take screenshots on lower API levels, you need to use <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/Screenshot#capture(android.app.Activity)"><strong>capture(Activity)</strong></a> or <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/Screenshot#capture(android.view.View)"><strong>capture(View)</strong></a> for those versions.</p><h3>Processing the screenshot</h3><p>In order to process the screenshot, we have to use two things: <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/ScreenCapture.html"><strong>ScreenCapture </strong></a>and <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/ScreenCaptureProcessor"><strong>ScreenCaptureProcessor</strong></a>.</p><p>There is a default implementation called <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/BasicScreenCaptureProcessor"><strong>BasicScreenCaptureProcessor</strong></a>, which does the following:</p><p>A basic <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/ScreenCaptureProcessor"><strong>ScreenCaptureProcessor</strong></a><strong> </strong>for processing a <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/ScreenCapture"><strong>ScreenCapture</strong></a>.</p><p>This will perform basic processing on the given <a href="https://developer.android.com/reference/android/support/test/runner/screenshot/ScreenCapture"><strong>ScreenCapture</strong></a><strong> </strong>such as saving to the public Pictures directory, given by android.os.Environment.getExternalStoragePublicDirectory(DIRECTORY_PICTURES), with a simple name that includes a few characteristics about the device it was saved on followed by a UUID.</p><p><strong>This API is currently in beta.</strong></p><h4>Taking a simple screenshot</h4><p>At this point, if you were to take a simple screenshot, you’d just have to use a function like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c3cd25f726142c6c23122cc4289ff33/href">https://medium.com/media/1c3cd25f726142c6c23122cc4289ff33/href</a></iframe><p><strong>WARNING</strong></p><p>Make sure you have <strong>WRITE_EXTERNAL_STORAGE</strong> permission added to the manifest (adding it only for debug build is fine). If you run on API 23+ (Marshmallow), you will also need to have those permissions granted before running the test.</p><p>You can “hack” this, by using <strong>installOptions</strong> in AGP (Android Gradle Plugin). Just put this in your <strong>build.gradle</strong> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4dd90976a5c082cc50ed763667c5dc8/href">https://medium.com/media/a4dd90976a5c082cc50ed763667c5dc8/href</a></iframe><h4>Custom ScreenCaptureProcessor</h4><p>If you want to set a custom name for your screenshots and save to a specific location, rather than default <strong>“screenshots”</strong> folder under <strong>“Picture”</strong> on the device. Since you could use other apps on the same device, it’ll be better to set up a specific folder on the device. I wanted to make it event better, so I made an implementation that also takes into account flavors and build types:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/622ff81bcaa2b7035168432b8bcac741/href">https://medium.com/media/622ff81bcaa2b7035168432b8bcac741/href</a></iframe><p>Now, in order to take screenshots we have to update the <strong>takeScreenshot(…)</strong> function a little:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc5bbe8ad400de7b414c07edc70e0148/href">https://medium.com/media/dc5bbe8ad400de7b414c07edc70e0148/href</a></iframe><h3>Android Test Orchestrator</h3><p>The next thing we have to do is to protect our UI tests against test crashes. Normally if you run a lot of tests and one of them crashes it will stop the rest of the remaining tests. If you want to avoid it then you have to use <a href="https://developer.android.com/training/testing/junit-runner"><strong>Android Test Orchestrator</strong></a> in your project.</p><p>A simple configuration for <a href="https://developer.android.com/training/testing/junit-runner"><strong>Android Test Orchestrator</strong></a> looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e63a788fd0217204e17915053c7b345/href">https://medium.com/media/0e63a788fd0217204e17915053c7b345/href</a></iframe><h3>Turning off the animations</h3><p>Another wise thing to do is to turn off the animations during tests. This setting could prevent unwanted lags and can speed up the tests. To do that, you just have to add <strong>animationsDisabled</strong> property to the<strong> build.gradle</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/584b73e233358501f8b299298e4815dd/href">https://medium.com/media/584b73e233358501f8b299298e4815dd/href</a></iframe><h3>Retrieve screenshots from the device</h3><p>If we run our tests now then we should see screenshots saved on the device. Great! But how do we pull them from the device to a specific directory on our PC?</p><p>To solve this we have to create a few Gradle Tasks</p><ul><li>First one for creating screenshots directory</li><li>Second one for fetching screenshots</li><li>And the last one for clearing screenshots from the device after fetching</li></ul><p>Fetching your screenshots will be done automatically, right after <strong>connectedDebugAndroidTest</strong> Gradle Task. To make this work, add this to your <strong>build.gradle</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f189f33e8c6f2839a7b14db912cc028/href">https://medium.com/media/7f189f33e8c6f2839a7b14db912cc028/href</a></iframe><p>Now, to run tests and fetch screenshots, just execute the following in you project’s directory:</p><pre>./gradlew connectedDebugAndroidTest</pre><p>You should see a new folder created right after, called <strong>“screenshots”</strong>.</p><p>If you want to learn more about ADB commands, you learn a lot here: <a href="https://developer.android.com/studio/command-line/adb">https://developer.android.com/studio/command-line/adb</a></p><h3>Show me the Github Repository</h3><p>To sum it up I’ve created a simple movie app on Github that you can find here:</p><p><a href="https://github.com/k0siara/AndroidMovieBox">k0siara/AndroidMovieBox</a></p><p>That’s all folks. Hope this helps you with building a good, well tested Android app. As always, if you have any questions you can either write a comment or message me directly. Bye and happy testing! :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b138f6d1eb8" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/easy-ui-and-screenshot-testing-on-android-2b138f6d1eb8">Easy UI And Screenshot Testing On Android</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>