<?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 Paolo Brandi on Medium]]></title>
        <description><![CDATA[Stories by Paolo Brandi on Medium]]></description>
        <link>https://medium.com/@paolo_noodles?source=rss-2eb698089435------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*dJyB4iZoiIw0gO_uMziypg.jpeg</url>
            <title>Stories by Paolo Brandi on Medium</title>
            <link>https://medium.com/@paolo_noodles?source=rss-2eb698089435------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:04:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paolo_noodles/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[RxJava().filter{ it.basic }]]></title>
            <link>https://medium.com/android-news/rxjava-filter-it-basic-d7787c33aa6d?source=rss-2eb698089435------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7787c33aa6d</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <dc:creator><![CDATA[Paolo Brandi]]></dc:creator>
            <pubDate>Mon, 08 Jul 2019 17:12:32 GMT</pubDate>
            <atom:updated>2019-07-08T19:31:40.688Z</atom:updated>
            <content:encoded><![CDATA[<h4>A “reactive” way to explain some key points and concepts regarding ReactiveX</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwKY1HaIOdRd236FNYIjqw.png" /></figure><p>This article is not meant to explain how ReactiveX works, there are already plenty of them out there (some link at the end for those who might be interested), but rather it wants to be a reference for some basic concepts and terminologies that might be more or less familiar. <br>It might be of interest for who is already familiar with ReactiveX world but sometimes gets confused or to who, instead, is new to it and wants to understand the meaning of some terms, before jumping into it.</p><p>Just one assumption before starting…</p><p>this article refers to the Java implementation of the ReactiveX API, more specifically to <a href="https://github.com/ReactiveX/RxJava/tree/2.x">RxJava 2.x.</a><br>If you are interested in the differences between this version and its brother RxJava 1.x, please read <a href="https://github.com/ReactiveX/RxJava/wiki/What&#39;s-different-in-2.0">this</a>.</p><p>Ready? Let’s start and subscribe to this <strong>article, by filtering </strong>only the basics of RxJava<strong> </strong>:)</p><pre>Observable article = RxJava().filter{ it.basic }<br>article.subscribe { readNext() }</pre><p>we will invoke <strong>readNext()</strong><em> </em>every time the article emits a new Rx basic concept.</p><p>Below the first emission :)</p><h4><strong>readNext() — An intro to </strong>ReactiveX</h4><p>From the official <a href="http://reactivex.io/intro.html">ReactiveX</a> page:</p><blockquote>ReactiveX is sometimes called “functional reactive programming” but this is a misnomer. ReactiveX may be functional, and it may be reactive, but “functional reactive programming” is a different animal. One main point of difference is that functional reactive programming operates on values that change <em>continuously</em> over time, while ReactiveX operates on <em>discrete</em> values that are emitted over time.</blockquote><p>…now…second emission…</p><h4>readNext() — Reactive</h4><p>ReactiveX may be Reactive.</p><p>Definition: <br><em>Reactive programming is a declarative programming paradigm concerned with data flows and the propagation of change over time. <br>With this paradigm is possible to express data flows, and any changing-state can be automatically propagated by the underlying execution model through the data flows.</em></p><p>…and….the third emission….you got it now, no?</p><h4>readNext() — Functional</h4><p>ReactiveX may be Functional.</p><p>Definition:<br><em>Functional programming is a declarative programming paradigm that treats computation as the evaluation of mathematical functions, using “pure” functions that don’t produce side effects, avoid changing-state and mutable data — e.g. the same input will always produce the same output.</em></p><p>In contrast to imperative programming which is done with statements and sequence of commands for changing the state and where data are mutable. <br>In functional programming data are immutable and new states are created from the previous ones.</p><h4>readNext() — Reactive eXtensions</h4><p>ReactiveX is a library built on the Reactive programming paradigm for composing asynchronous and event-based programs by using <strong>observables</strong> while abstracting away concerns about things like low-level threading, synchronization, thread-safety, concurrent data structures, and non-blocking I/O.</p><p>It is called ReactiveX (a.k.a. Reactive Extensions) because:</p><ul><li>it <strong>extends</strong> <a href="http://en.wikipedia.org/wiki/Observer_pattern">the observer pattern</a> to support sequences of data and/or events</li><li>it extends/combine Reactive Programming with Functional Programming by adding <strong>operators</strong> that allow you to compose sequences together declaratively.</li></ul><h4>readNext() — RxOperators</h4><p>ReactiveX offers a big set of <a href="http://reactivex.io/documentation/operators.html">Operators</a> for a different type of operations.<br>In general, operators can be chained to each other, can be applied to data flows, can transform one type of data to another, can be composed to produce more complicated operators, can be extended in order to create <a href="http://reactivex.io/documentation/implement-operator.html">custom operators</a>.</p><p>Operators can be <a href="http://reactivex.io/documentation/operators.html#categorized">grouped by category</a>:</p><ul><li>Creating Observable such as <em>create(), just(), empty(), defer()…</em></li><li>Transforming Observable such as <em>map(), flatMap()…</em></li><li>Filtering Observable such as <em>filter(), skip(), take()…</em></li><li>Combining Observable such as<em> merge(), zip(), switch()…</em></li><li>Utility Operators such as <em>observeOn(), subscribeOn(), doOn()…</em></li><li>Conditional Operators such as <em>contains(), takeIf()…</em></li><li>Mathematical/Aggregate Operators such as max(), min(), concat()…</li><li>and others…</li></ul><p><a href="http://reactivex.io/documentation/operators.html">Here</a> a full list of Operators and their documentation that explains how each of them works and is meant to be used with the help of a typical <a href="https://rxmarbles.com/">marble diagrams</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*CPYBlVVIBgSqvM9dU37hMQ.png" /><figcaption>Example of a marble diagram for the operator map().</figcaption></figure><h4>readNext() — Push Pattern</h4><p>ReactiveX follows the “<em>push</em>” pattern where everything is data, <em>streams of data </em>which can be emitted by a <em>Source</em> and consumed by other entities called <em>Consumers</em>. Data streams can be manipulated and combined together before getting consumed.</p><h4>readNext() — Source of data</h4><p>Based on the nature of the source there might be different types of streams and consumers.</p><h4>readNext() — ObservableSource</h4><p>In RxJava 2.x, <em>ObservableSource</em> is an Interface for a type of source that might produce <strong>0 to many items or error</strong>, which allows consumer such as <em>Observer</em> to subscribe to this source of data.</p><pre><em>/**<br> * Represents a basic, non-backpressured {</em><strong><em>@link </em></strong><em>Observable} source base interface,<br> * consumable via an {</em><strong><em>@link </em></strong><em>Observer}.<br> *<br> * </em><strong><em>@param </em></strong>&lt;<em>T</em>&gt; <em>the element type<br> * </em><strong><em>@since </em></strong><em>2.0<br> */<br></em>public interface ObservableSource&lt;T&gt; {<br><br>    <em>/**<br>     * Subscribes the given Observer to this ObservableSource instance.<br>     * </em><strong><em>@param </em></strong><em>observer the Observer, not null<br>     * </em><strong><em>@throws </em></strong><em>NullPointerException if {</em><strong><em>@code </em></strong><em>observer} is null<br>     */<br>    </em>void subscribe(@NonNull Observer&lt;? super T&gt; observer);<br>}</pre><h4>readNext() — Observable</h4><p><a href="http://reactivex.io/documentation/observable.html">Observable</a> is an implementation of the ObservableSource, which wraps up the data flow and provides a full set of RxOperators. It should be seen as a channel to connect sources and observers.</p><h4>readNext() — Observer</h4><p>An observer is the consumer of the data. In RxJava it is an interface that provides the mechanism to listen to each emission, error, and termination of the stream.</p><pre>public interface Observer&lt;T&gt; {<br><br>    <em>/**<br>     * Provides the Observer with a new item to observe.<br>     * &lt;p&gt;<br>     * The {</em><strong><em>@link </em></strong><em>Observable} may call this method 0 or more times.<br>     * &lt;p&gt;<br>     * The {</em><strong><em>@code </em></strong><em>Observable} will not call this method again after it calls either {</em><strong><em>@link </em></strong><em>#onComplete} or<br>     * {</em><strong><em>@link </em></strong><em>#onError}.<br>     *<br>     * </em><strong><em>@param </em></strong><em>t<br>     *          the item emitted by the Observable<br>     */<br>    </em>void onNext(@NonNull T t);<br><br>    <em>/**<br>     * Notifies the Observer that the {</em><strong><em>@link </em></strong><em>Observable} has experienced an error condition.<br>     * &lt;p&gt;<br>     * If the {</em><strong><em>@link </em></strong><em>Observable} calls this method, it will not thereafter call {</em><strong><em>@link </em></strong><em>#onNext} or<br>     * {</em><strong><em>@link </em></strong><em>#onComplete}.<br>     *<br>     * </em><strong><em>@param </em></strong><em>e<br>     *          the exception encountered by the Observable<br>     */<br>    </em>void onError(@NonNull Throwable e);<br><br>    <em>/**<br>     * Notifies the Observer that the {</em><strong><em>@link </em></strong><em>Observable} has finished sending push-based notifications.<br>     * &lt;p&gt;<br>     * The {</em><strong><em>@link </em></strong><em>Observable} will not call this method if it calls {</em><strong><em>@link </em></strong><em>#onError}.<br>     */<br>    </em>void onComplete();<br><br>}</pre><ul><li><strong>onNext():</strong> an Observable calls this method whenever the Observable emits an item. This method takes as a parameter the item emitted by the Observable.</li><li><strong>onError(): </strong>an Observable calls this method to indicate that it has failed to generate the expected data or has encountered some other error. It will not make further calls to onNext or onCompleted. The onErrormethod takes as its parameter an indication of what caused the error.</li><li><strong>onCompleted():</strong> an Observable calls this method after it has called onNext for the final time if it has not encountered any errors.</li></ul><h4>readNext() — MaybeSource, Maybe and MaybeObserver</h4><p>In RxJava 2.x, <em>MaybeSource</em> is an Interface for a type of source that might produce <strong>0 to 1 item or error</strong>, which allows consumer such as <em>MaybeObserver</em> to subscribe to this source of data. <em>Maybe</em> is the abstract implementation which provides a set of operators.</p><pre>public interface MaybeObserver&lt;T&gt; {<br><br>    <em>/**<br>     * Notifies the MaybeObserver with one item and that the {</em><strong><em>@link </em></strong><em>Maybe} has finished sending<br>     * push-based notifications.<br>     * &lt;p&gt;<br>     * The {</em><strong><em>@link </em></strong><em>Maybe} will not call this method if it calls {</em><strong><em>@link </em></strong><em>#onError}.<br>     *<br>     * </em><strong><em>@param </em></strong><em>t<br>     *          the item emitted by the Maybe<br>     */<br>    </em>void onSuccess(@NonNull T t);<br><br>    <em>/**<br>     * Notifies the MaybeObserver that the {</em><strong><em>@link </em></strong><em>Maybe} has experienced an error condition.<br>     * &lt;p&gt;<br>     * If the {</em><strong><em>@link </em></strong><em>Maybe} calls this method, it will not thereafter call {</em><strong><em>@link </em></strong><em>#onSuccess}.<br>     *<br>     * </em><strong><em>@param </em></strong><em>e<br>     *          the exception encountered by the Maybe<br>     */<br>    </em>void onError(@NonNull Throwable e);<br><br>    <em>/**<br>     * Called once the deferred computation completes normally.<br>     */<br>    </em>void onComplete();<br>}</pre><h4>readNext() — SingleSource, Single and SingleObserver</h4><p>In RxJava 2.x, <em>SingleSource</em> is an Interface for a type of source that might produce <strong>1 item or error</strong>, which allows consumer such as <em>SingleObserver</em> to subscribe to this source of data. <em>Single</em> is the abstract implementation which provides a set of operators.</p><pre>public interface SingleObserver&lt;T&gt; {<br><br>    <em>/**<br>     * Notifies the SingleObserver with a single item and that the {</em><strong><em>@link </em></strong><em>Single} has finished sending<br>     * push-based notifications.<br>     * &lt;p&gt;<br>     * The {</em><strong><em>@link </em></strong><em>Single} will not call this method if it calls {</em><strong><em>@link </em></strong><em>#onError}.<br>     *<br>     * </em><strong><em>@param </em></strong><em>t<br>     *          the item emitted by the Single<br>     */<br>    </em>void onSuccess(@NonNull T t);<br><br>    <em>/**<br>     * Notifies the SingleObserver that the {</em><strong><em>@link </em></strong><em>Single} has experienced an error condition.<br>     * &lt;p&gt;<br>     * If the {</em><strong><em>@link </em></strong><em>Single} calls this method, it will not thereafter call {</em><strong><em>@link </em></strong><em>#onSuccess}.<br>     *<br>     * </em><strong><em>@param </em></strong><em>e<br>     *          the exception encountered by the Single<br>     */<br>    </em>void onError(@NonNull Throwable e);<br>}</pre><h4>readNext() — CompletableSource, Completable and CompletableObserver</h4><p>In RxJava 2.x, <em>CompletableSource</em> is an Interface for a type of source that might produce <strong>0 item or error</strong>, which allows consumer such as <em>CompletableObserver</em> to subscribe to this source of data. <em>Completable</em> is the abstract implementation which provides a set of operators.</p><pre>public interface CompletableObserver {<br><br>    <em>/**<br>     * Called once the deferred computation completes normally.<br>     */<br>    </em>void onComplete();<br><br>    <em>/**<br>     * Called once if the deferred computation &#39;throws&#39; an exception.<br>     * </em><strong><em>@param </em></strong><em>e the exception, not null.<br>     */<br>    </em>void onError(@NonNull Throwable e);</pre><h4>readNext() — Publisher, Flowable and Subscriber</h4><p>The relationship between Publisher, Flowable and Subscriber is the same as for ObservableSource, Observable and Observer, with the only difference a Flowable supports Backpressure.</p><h4>readNext() — Backpressure</h4><p>Backpressure is the ability to handle a source of data where the emission rate is higher than the rate a consumer can actually consume these items. For example, this is true for real-time data such as GPS coordinates or motion events. ReactiveX provides different policies to handle these kinds of scenarios. Flowable is the only data stream to be able to support Backpressure. For the nature of the problem is understandable the reason Maybe, Single and Completable do not need to support this capability.</p><h4>readNext() — Hot vs Cold Observable</h4><ul><li><strong>Cold</strong> observables can be created multiple times and each instance can be triggered on its own. It starts emitting items once an observer subscribes to it.</li><li><strong>Hot</strong> observables are like a “stream” of ongoing events. Observers can come and go, but the stream is created ones and just keeps going.</li></ul><h4>readNext() — Schedulers</h4><p><a href="http://reactivex.io/documentation/scheduler.html">Schedulers</a> are the ReactiveX way to handle asynchronous jobs, abstracting away concurrency, synchronization and threading management, allowing to switch from a thread to another one in an easy way.</p><p>RxJava features several standard schedulers:</p><ul><li>Schedulers.computation(): Run computation intensive work on a fixed number of dedicated threads in the background. Most asynchronous operators use this as their default Scheduler.</li><li>Schedulers.io(): Run I/O-like or blocking operations on a dynamically changing set of threads.</li><li>Schedulers.single(): Run work on a single thread in a sequential and FIFO manner.</li><li>Schedulers.trampoline(): Run work in a sequential and FIFO manner in one of the participating threads, usually for testing purposes.</li></ul><h4>readNext() — subscribeOn() vs observerOn()</h4><ul><li><strong>subscribeOn()</strong> defines the Scheduler where the source work will be performed on. Since there is only one initial source for an Observable chain, it makes sense to only have one <em>subscribeOn()</em> operator. Subsequent calls to<em> subscribeOn() </em>will not affect or override the previous configuration.</li><li><strong>observeOn()</strong> defines the Scheduler where all downstream operations will be performed. In other words, it changes the Scheduler for all operators <strong>after</strong> it is applied. Since there can be many subsequent calls to it, having multiple <em>observeOn() </em>calls in a single chain makes sense and it’s actually a good practice depending on the kind of job needs to be performed.</li></ul><h4>readNext() — Upstream vs Downstream</h4><pre>source<br>  .operator1()<br>  .operator2()<br>  .operator3()<br>  .operator4()<br>  .subscribe(consumer)</pre><p>Imagine ourselves on the step defined by operator2:</p><ul><li><strong>upstream</strong> is anything towards the source</li><li><strong>downstream</strong> is anything towards the subscribe(consumer)</li></ul><h4>onComplete()</h4><p>That stream is ended :) That is it for now.<br>If you are more interested in Rx and how it works you can find some references that can help you out.</p><h4><em>References:</em></h4><ul><li><a href="http://reactivex.io/">ReactiveX Official Website</a></li><li><a href="https://github.com/ReactiveX/RxJava/">RxJava GitHub</a></li><li><a href="http://reactivex.io/RxJava/javadoc/">RxJava Javadoc</a></li><li><a href="https://medium.com/swlh/reactive-programming-with-kotlin-for-android-9e20efa0c130">Reactive Programming with Kotlin for Android</a> by <a href="https://medium.com/@joseangel.zamora.cobo">Jose Angel Zamora</a></li><li><a href="https://medium.com/upday-devs/building-a-reactive-mindset-78a299160729">Building A Reactive Mindset</a> by <a href="https://medium.com/@florina.muntenescu">Florina Muntenescu</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7787c33aa6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/rxjava-filter-it-basic-d7787c33aa6d">RxJava().filter{ it.basic }</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Architecture Patterns: Model-View-Controller]]></title>
            <link>https://medium.com/android-news/architecture-patterns-model-view-controller-de312417b4bd?source=rss-2eb698089435------2</link>
            <guid isPermaLink="false">https://medium.com/p/de312417b4bd</guid>
            <category><![CDATA[architectural-design]]></category>
            <category><![CDATA[software-design-patterns]]></category>
            <category><![CDATA[mvc]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Paolo Brandi]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 17:12:18 GMT</pubDate>
            <atom:updated>2019-06-27T09:35:57.054Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*FXMzw9pL0TSe7UfsQAIbwA.jpeg" /></figure><p>Model View Controller (a.k.a. MVC) is one of the most misquoted and argued architecture pattern I have ever seen. It is incredible the number of blogs, articles, and different implementations out there, but still, the confusion reigns and also many developers experienced and not, struggle to explain it and find it difficult to understand.</p><h4>The main reason for the confusion…</h4><p>is the overuse/misuse of the term <strong>Controller</strong>. Plus, most of the times diagrams are misleading because it’s not clear if they are UML diagrams and if so, what kind of diagram? What is the meaning of each arrow?</p><p>In this article, I will try to explain it with a historical approach which I personally think it helps a lot to better understand where the term Controller comes from and how the pattern evolved.</p><h4>Some history…</h4><p>The MVC in its original form was first introduced with Smalltalk-76 by its creator <a href="https://en.wikipedia.org/wiki/Trygve_Reenskaug">Trygve Reenskaug</a> in the 1970s and later implemented in Smalltalk-80 in the 1980s, but formally explained for the first time in an article on <a href="https://dl.acm.org/citation.cfm?id=50757.50759"><em>The Journal of Object Technology</em></a> in 1988.</p><p>MVC was born as a GUI (Graphical User Interface) architecture style and at that time things were clearly different than today, just think of a screen with black and white UI, GUI was not complex and probably didn’t have much logic either.<br>The concept of a framework of reusable UI components was still far from what we have today and UI elements such as Buttons, Text, Checkboxes were just able to draw themselves, they didn’t have any capability to detect inputs from a keyboard or a mouse which was the job of the Controller.</p><h3>MVC Concept</h3><p>The main purpose of MVC was to introduce a clear <strong>separation </strong>between the data layer and the presentation layer, making the domain objects (<strong>model</strong>) unaware of the presentation objects (<strong>views and controllers</strong>). In order to achieve that, it uses the <em>Observer pattern </em>to support multiple presentations (<em>Observers</em>) of one single domain model (<em>Observable</em>).<br>Later, Smalltalkers also realized this way they could make <em>reusable widgets</em> (a.k.a. controls as <strong>View-Controller pairs</strong>), that could be used as out-of-the-box solutions to build GUIs for future applications (kind of what we have today).</p><ul><li><strong>View </strong>is a widget on the screen surface, it is only able to draw itself. Not able to handle inputs.</li><li><strong>Controller</strong> is responsible to handle user interactions/inputs such as keyboard or mouse events for a single View.</li><li><strong>Model </strong>is<strong> </strong>the data layer, responsible for managing the business logic and data sources such as databases or network APIs.</li></ul><p>We can summarize 3 key points:</p><ol><li>Separation of concerns between UI and Model</li><li>GUI divides input and output handling by pairs &lt;View, Controller&gt;. There is no direct communication involved with each other.</li><li>Model is independent and loosely coupled with Views and Controllers (Observer Pattern)</li></ol><h3>MVC Evolution</h3><p>Like anything else, also MVC evolved into different variations, such as the <em>Classic </em>MVC or <em>Application Model </em>MVC and different implementations such <em>Passive Model </em>or <em>Active Model</em> in order to satisfy all the different needs coming from the increasing complexity of GUIs and application logic. But the variations share all the same concept, which has never changed.</p><h3>Classic MVC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*tHe5w9qo4CJ-Y0hJumabCA.png" /><figcaption>Active Model View Controller Communication diagram</figcaption></figure><p>The diagram above is a UML Communication diagram which shows how MVC components collaborate, describes the behavior of the components involved. Bear in mind it’s not a Class diagram. E.g. <strong>there is no direct communication involved between a View and its Controller</strong>.<br>In simple words, the controller receives inputs from the user, commands the model as appropriate, the model performs some business logic, changes its state and raise an event to notify that to any view listening to that event, the responding view asks relevant data to the model and accordingly changes its display state.</p><h4>Active Model vs Passive Model</h4><p>The example above is also known as <strong>Active Model MVC</strong>, where it is Model responsibility to notify a state change.<br>Instead, in the <strong>Passive Model MVC,</strong> the Controller commands the Model and is also responsible for notifying the View of a state change. Then, the view queries the Model as usual to retrieve the new state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*AODA5dytWxOzvhTDaUCzaw.png" /><figcaption>Passive Model View Controller Communication diagram</figcaption></figure><p>The “Classic” MVC is the first implementation of the pattern as it was formalized by Smalltalk. It is really basic and simple, it achieves the main purpose the pattern was introduced for in the first place. It suits very well for simple GUI with no much UI logic involved.</p><h3>Application Model MVC</h3><p>With the increasing complexity of the UI logic, the Classic MVC showed its first limits.</p><p>Where should the UI logic belong?</p><ol><li>In the Model? This would break the <em>separation of concern</em> principle. The Model would be responsible for either business logic and UI logic. Moreover, it would make the Model depend on the View as well. Difficult to reuse and maintain.</li><li>In the Controller or the View? Moving any UI logic into either the View or the Controller would work, but it would make the widget not generic anymore, plus it would break the single responsibility principle. The Controller is responsible to handle inputs and the View is responsible to draw itself.</li></ol><p>Smalltalkers came up with a new solution, a component with the only responsibility to deal with UI logic and able to operate between the View/Controller pairs and the Model, called the <em>Application Model.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*g9R0NQ6yooBwacFo40ZL_g.png" /><figcaption>Application Model MVC Communication diagram</figcaption></figure><p>The only difference is that all the communication passes through the Application Model from Controller to the Model and back to the View in the same way it works for the Classic MVC. Application model behaves as a proxy. It introduces, of course, an extra layer but it keeps the UI logic and the business logic well separate and the Model still independent from the UI.</p><h4><strong>Moving forward…</strong></h4><p>With the creations of more generalized frameworks for building GUI for client-side applications, UI widgets became more and more reusable and powerful combining the View and the Controller capabilities in one single reusable out-of-the-box solution like today.</p><p>It is easy to see how the MVC at some point evolved into MVP…</p><h3>MVC in Android</h3><p>In many blogs or usual StackOverflow answers, I often read that Android has been designed thinking of MVC, with the XML layout being the View, Activities or Fragments being the Controller… or both View and Controller. I think this is nonsense.</p><p>Implementing the MVC exactly as it was thought by Smalltalk it is not really possible since today Android framework provides widgets which are capable to handle user inputs. The role of the Controller is gone.</p><p>What we can do is to apply the same principles, the communication and data flow to build an application that makes usage of MVC in a more modern way:</p><ul><li>The Activities, Fragments, and Views should be the <em>View</em> in the MVC.</li><li>The <em>Controller</em> and <em>Model</em> should be separate classes that don’t extend or use any Android class.</li><li>The <em>View</em> and the <em>Controller</em> depend on each other, but for testing purpose and to respect the <em>Dependency inversion principle, </em>the <em>View</em> should implement an <em>Interface</em> and the <em>Controller</em> should reference that and not the concrete class directly.</li></ul><p>As a reference, in my <a href="https://github.com/n00dIes/android-mvc-sample">GitHub</a> there is a basic sample of how to apply MVC in Android, feel free to check that out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*xEr8zkuCY4BQxC-K3uMGVQ.png" /><figcaption>Class diagram of an implementation of MVC</figcaption></figure><p><em>References:</em></p><ul><li><a href="https://martinfowler.com/eaaDev/uiArchs.html">GUI Architectures by Martin Fowler</a></li><li><a href="http://aviadezra.blogspot.com/2008/06/mvc-model-view-controller-design.html">MVC (Model View Controller) Design Pattern in the late 70s by Aviad Ezra</a></li><li><a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model View Controller — Wikipedia</a></li><li><a href="https://dl.acm.org/citation.cfm?id=50757.50759">A cookbook for using the model-view-controller user interface paradigm in Smalltalk-80 by Glen E. Krasner, Stephen T. Pope</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de312417b4bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/architecture-patterns-model-view-controller-de312417b4bd">Architecture Patterns: Model-View-Controller</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android API Level, backward and forward compatibility]]></title>
            <link>https://medium.com/android-news/android-api-level-backward-and-forward-compatibility-10e6d31cb848?source=rss-2eb698089435------2</link>
            <guid isPermaLink="false">https://medium.com/p/10e6d31cb848</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Paolo Brandi]]></dc:creator>
            <pubDate>Sun, 09 Jun 2019 23:35:54 GMT</pubDate>
            <atom:updated>2019-06-14T05:02:32.671Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ekDGh5K4F6QwKg30TIN5A.jpeg" /></figure><p>If you get to read this article it might mean you are wondering things like:</p><ul><li>What is an API?</li><li>What does API Level mean?</li><li>How to use <strong>compileSdkVersion</strong>,<em> </em><strong>minSdkVersion</strong><em> </em>or<em> </em><strong>targetSdkVersion?</strong></li><li>How can I ensure my app will work properly on devices with different versions of the OS?</li></ul><p>All these concepts are related to each other and I will try to clarify them to you in this article in a simple but effective way.</p><p>In order to do so, we need to have in mind the difference between <strong>SDK</strong> and <strong>API </strong>in software development and the meaning of<strong> API Level </strong>in the Android ecosystem.</p><p>In Android, it’s true that there is a 1:1 relationship between the SDK and the API and often these two terms are used as synonymous, but it’s important to understand they are not the same thing. <br>But it’s correct to say that for each Android version there is an SDK and there is an equivalent API and API Level.</p><h4><strong>SDK</strong></h4><p>It stands for <em>Software Development Kit</em>. Think of the word “kit”… it is exactly a collection or a set of different tools, libraries, documentation, samples to help developers to build, debug and run Android apps. Along with an SDK, an API is provided.</p><p>Opening the <em>SDK Manager</em> in Android Studio shows much clearer what is part of an Android SDK. <br>The first tab <em>SDK Platform</em> lists the SDKs of each Android version.<br>As per example, shown in the picture below, Android 9.0 (aka Pie) SDK contains:</p><ul><li>Android SDK Platform 28 (that’s the framework <strong>API</strong>)</li><li>Source code for Android 28 (that’s the <strong>implementation</strong> of the API, as you can see is optional… keep this in mind)</li><li>and a bunch of other stuff… like different system images for the Android emulator.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*TjhjZGqSAtXJHRXKPwv2Mw.png" /><figcaption>An overview of the SDK in Android Studio SDK Manager.</figcaption></figure><p>The second tab <em>SDK Tools</em> shows a bunch of other tools which are still part of the SDK, but platform version independent, which means they might be released or updated separately.</p><h4><strong>API</strong></h4><p>It stands for <em>Application Programming Interface. </em>It is simply an interface, an abstraction layer that allows communications between two different “pieces” of software. It works as a contract between the provider (e.g. a library) and the consumer (e.g. an app) <br>It is a set of formal definitions such as classes, methods, functions, modules, constants that can be used by other developers to write their code. Also, an API does not include implementation.</p><h4><strong>API Level</strong></h4><p>API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.<br>Usually, updates to the framework API are designed so that the new API remains compatible with earlier versions of the API, for this reason, most of the changes to the new API are additive and the old parts of API are deprecated but not removed.</p><p>But now someone could argue…</p><p>if an Android API doesn’t provide implementation and the <em>SDK Manager </em>offers an optional downloadable API source code as part of the SDK, where is the actual implementation?</p><p>The answer is easy. <strong>On the device.</strong></p><p>Let’s go through this quickly…</p><p><strong>From source code to an APK file</strong></p><p>Generally, an Android project is composed by the code developers write using Android API (the application module), plus some other libraries/dependencies (.jar, AAR, local modules…etc) and some resources. <br>The compilation process converts Java/Kotlin code, dependencies included (one reason to shrink your code!), into DEX byte-code and then compressed everything into an APK file along with some resources. At this stage, the implementation of the API is not included in the resulting APK!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*Z88rT6JNgXAwvoc2npI1wA.png" /><figcaption>Build process — <a href="https://developer.android.com/studio/build">Android Developers</a></figcaption></figure><p><strong>DEX files and Android Runtime</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*vcHku6DKsCiLOJmr03BnUw.png" /><figcaption>Android Architecture — <a href="https://developer.android.com/guide/platform">Android Developers</a></figcaption></figure><p>The Android Runtime is where all the dirty job is done and where DEX files are executed. It is made of two main components:</p><ul><li>a <strong>Virtual Machine</strong> in order to take advantages of code portability and platform independence. Starting from Android 5.0 (Lollipop) the old runtime environment, <em>Dalvik Virtual Machine</em>, has been totally replaced by the new <a href="https://source.android.com/devices/tech/dalvik/index.html"><em>Android RunTime</em> (ART)</a>. Dalvik used a JIT compiler, whereas ART uses AOT (Ahead of time) compilation plus JIT for runtime code profiling.</li><li><strong>Core Libraries</strong> are standard Java libraries and Android libraries. In simple words, this is where the implementation of the API resides.<br><strong>The API version available at this level is the one offered by the version of the Android platform in which the app is running.<br></strong>For example, if the actual device has installed Android 9 (Pie), all the APIs until API Level 28 are available.</li></ul><p>If the few key concepts of how the Android Runtime works and what is the role of the API is clear so far, then it should be quite easy to understand <strong>backward/forward compatibility</strong> and the usage of <strong>compileSdkVersion, minSdkVersion </strong>and<strong> targetSdkVersion</strong>.</p><h4>compileSdkVersion</h4><p>This value is used only to tell <em>Gradle</em> what version of the SDK to compile your app with. For developers, it allows accessing to all the APIs available up to API Level set to <em>compileSdkVersion</em>.</p><p><strong>It is strongly recommended to compile against the latest SDK version:</strong></p><ul><li>a high API Level allows developers to take advantages of the latest APIs and capabilities provided by new platforms.</li><li>in order to use the latest <em>SupportLibrary,</em> <em>compileSdkVersion</em> has to match the <em>SupportLibrary</em> version too. <br>For example, in order to use <em>SupportLibrary-28.x.x</em>, <em>compileSdkVersion</em> has to be set to <em>28</em> as well.</li><li>for migrating to/using <a href="https://developer.android.com/jetpack/androidx"><em>AndroidX</em></a>, <em>compileSdkVersion</em> has to be set at <em>28</em> at least.</li><li>getting ready to satisfy <a href="https://developer.android.com/distribute/best-practices/develop/target-sdk">Google Play’s target API level requirement</a>. As announced by Google, in order to spread new Android versions quicker out in the market, every year Google will enforce a minimum target API Level for new applications and updates. More info <a href="https://developer.android.com/distribute/best-practices/develop/target-sdk">here</a> and <a href="https://android-developers.googleblog.com/2019/02/expanding-target-api-level-requirements.html">here</a>.</li></ul><p>Android applications are forward-compatible with new versions of the Android platform because API changes are generally additive and old APIs might be deprecated, but not removed.<br>That means <strong>forward compatibility</strong> is basically guaranteed by the platform and running an application on a device with a higher API Level than the one specified in <em>compileSdkVersion</em> does not have any runtime issue, the application runs as expected on newer platform versions too.</p><p>For example:</p><p><strong>App</strong> + <strong><em>compileSdkVersion</em> = 26</strong> and using an API <em>xyz()</em> introduced in <strong>API Level 26</strong> can run on a device with Android 8 Oreo (API Level 26).<br>The same app can run on a device with Android 9 Pie (API Level 28) since the API<em> xyz()</em><strong> </strong>is still available in API Level 28<strong>.</strong></p><h4>minSdkVersion</h4><p>This value specifies the minimum API Level in which the application is able to run. <strong>It’s the minimum requirement. If not specified, the default value is 1.</strong></p><p>It is developers responsibility to set a proper value and ensure the application runs properly down to this API Level. This is called <strong>backward compatibility</strong>.<br>During development, <em>Lint</em> will also warn developers when trying to use any API above the specified <em>minSdkVersion</em>. <strong>It is really important to not ignore these warnings and fix them!</strong><br>In order to provide <strong>backward compatibility, </strong>developers can check at runtime the platform version and use a new API on newer versions of the platform and old API on older versions or, depending on the case, using some static libraries which offer backward compatibility.</p><p>It is also important to mention Google Play Store uses this value to determinate if an app can be installed on a specific device by matching the device platform version with the app <em>minSdkVersion</em>.<br>Developers should be really careful when picking this value since backward compatibility is not guaranteed by the platform.<br>Picking a “right” value for a project is also a business decision since it affects how big is the audience the application is made for. Have a look at the <a href="https://developer.android.com/about/dashboards">platform distribution</a>.</p><p>For example:<br><strong>App</strong> + <strong><em>compileSdkVersion</em> = 26 </strong>+ <strong><em>minSdkVersion</em> = 22 </strong>and using an API <em>xyz()</em> introduced in <strong>API Level 26</strong> can run on a device with Android 8 Oreo (API Level 26).</p><p>The same app can be installed and run on an older device with Android 5.1 Lollipop (API Level 22), where the API <em>xyz()</em><strong> </strong>does not exist. If no backward compatibility has been provided by developers either with runtime checks or some sort of libraries, then the application will crash as soon as it tries to access the API <em>xyz()</em>.</p><h4>targetSdkVersion</h4><p>This value specifies the API Level on which the application is designed to run.<br>It doesn’t have to be confused with <em>compileSdkVersion. </em>The latter is only used at compile time and it makes new APIs available to developers. The former, instead, is part of the APK (as well as the <em>minSdkVersion</em>) and changes runtime behavior. It is the way developers can control <strong>forward compatibility</strong>.<br>Sometimes there might be some API changes on the underlying system that can affect how an application behaves when is running on a new runtime environment.<br>Targeting an application to a specific version enables all of those system runtime behaviors, which are dependent on that specific version of the platform. If an app is not ready to support these runtime behavior changes it is likely going to crash.<br>A simple example is the <a href="https://developer.android.com/about/versions/marshmallow/android-6.0-changes">Runtime Permission</a>, which has been introduced with Android 6 Marshmallow (API Level 23).<br>It is possible for an application to compile against API Level 23, but targeting API Level 22 if it is not ready yet to adopt the new runtime permission model.<br>In this way, an application can still be forward compatible without enabling the new runtime behavior.</p><p>Anyway, as already mentioned Google is enforcing apps to satisfy new target API level requirements, so it should be a high priority to always update this value.</p><p>Putting all together at the end there is a clear relationship</p><pre>minSdkVersion ≤ targetSdkVersion ≤ compileSdkVersion</pre><p>Keep in mind it is highly recommended to compile against the latest API Level and try to have <strong>targetSdkVersion == compileSdkVersion.</strong></p><p><strong>References:</strong></p><ul><li><a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element.html">uses-sdk-element documentation — Android Developers</a></li><li><a href="https://en.wikipedia.org/wiki/Android_Runtime">Android Runtime — Wikipedia</a></li><li><a href="https://github.com/dogriffiths/HeadFirstAndroid/wiki/How-Android-Apps-are-Built-and-Run">How Android Apps are built and run — David Griffiths GitHub</a></li><li><a href="https://developer.android.com/guide/platform#art">Platform Architecture — Android Developers</a></li><li><a href="https://source.android.com/devices/tech/dalvik/index.html">Android RunTime (ART) and Dalvik — Android Source</a></li><li><a href="https://developer.android.com/distribute/best-practices/develop/target-sdk">Meet Google Play’s target API level requirement — Android Developers</a></li><li><a href="https://developer.android.com/studio/build">Configure your Build — Android Developers</a></li><li><a href="https://medium.com/androiddevelopers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd">Picking your compileSdkVersion, minSdkVersion and targetSdkVersion — Ian Late Medium</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10e6d31cb848" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/android-api-level-backward-and-forward-compatibility-10e6d31cb848">Android API Level, backward and forward compatibility</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to manage a complex DeepLinks scheme on your Android App]]></title>
            <link>https://medium.com/android-news/how-to-manage-a-complex-deeplinks-scheme-on-your-android-app-d441143cec7e?source=rss-2eb698089435------2</link>
            <guid isPermaLink="false">https://medium.com/p/d441143cec7e</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[deep-linking]]></category>
            <dc:creator><![CDATA[Paolo Brandi]]></dc:creator>
            <pubDate>Mon, 27 May 2019 20:55:23 GMT</pubDate>
            <atom:updated>2019-06-13T10:11:34.616Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*OO4O8vPO0JuTkH2P4w_cFA.png" /></figure><p>DeepLinks are essential key elements to a company marketing strategy to engage new customers and bring them straight to your App as much as to retain those users, who are already customers, providing a better experience and combining web and native App content together under the same ecosystem.</p><p>As a result of web contents growing, URLs are expanding and becoming really complex supporting different domains/subdomains, HTTP/HTTPS, dynamic and localized paths etc…</p><h4>Defining DeepLinks in the AndroidManifest.xml</h4><p>If you are familiar with the Android Manifest and Intent Filters you should recognize this:</p><pre>&lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt;<br>        <br>        &lt;data android:scheme=&quot;app_scheme&quot;<br>              android:host=&quot;app_host&quot;<br>              android:path=&quot;/path_example&quot; /&gt;<br>&lt;/intent-filter&gt;</pre><p>this is how a deep-link as app_scheme://app_host/path_example is defined on Android in order to be handled by the App. It might be a native deep-link, like the one in the snippet or a Web URL which might have many variations, as mentioned before, and can make it hard to manage.</p><h4><strong>What is the problem?</strong></h4><p>Let’s say we have to handle some web URLs which point to <strong>10</strong> different pages of your web site, which means you now have to support <strong>10</strong> different paths, one of each URL. You end up with an intent-filter made of <strong>10</strong> &lt;/data&gt; entries. Not bad so far… but what if for each of them you have to support both http and https then you end up with <strong>10*2 = 20 entries</strong>…</p><pre>&lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt;        </pre><pre><br>        &lt;data android:scheme=&quot;http&quot;<br>              android:host=&quot;www.example.com&quot;<br>              android:path=&quot;/path_example&quot; /&gt;</pre><pre>        &lt;data android:scheme=&quot;https&quot;<br>              android:host=&quot;www.example.com&quot;<br>              android:path=&quot;/path_example&quot; /&gt;</pre><pre>&lt;/intent-filter&gt;</pre><p>yes, your manifest is getting bigger now! But we can make it worse… what if you have to support <strong>2 domains </strong><a href="http://www.example.com`/">www.example.com</a>and m.example.com. Now you have <strong>20*2 =40</strong> entries… all of them in your AndroidManifest.xml!</p><p>It is pretty clear what I want to point out. This number can be much higher and your manifest can contain lots of lines of code only to define deep-links, which can be really difficult to maintain at some point. <br>Take into consideration that this is only an example of a simple use case, with simple static paths and two domains.<br>Paths can easily increase the number of &lt;/data&gt; entries depending on the structure of the path itself which can variate from case to case.</p><p><strong>but… Android provides wildcards and regex for path/pathPattern/pathPrefix?!</strong></p><p>Yes and no! Unfortunately Android doesn’t really support regex as anyone could expect, but a really limited and obsolete set of rules to help developers define some patterns. In some cases it might help, in other cases, it might not. It doesn’t provide the flexibility developers should benefit from, but instead, it forces developers to stick with a static set of rules to define patterns to match any possible URL variation.</p><p>You can find more details <a href="https://developer.android.com/guide/topics/manifest/data-element.html">here</a></p><p><strong>A use case…</strong></p><p>just to give you an example (from a real use case I had to deal with)… <br>let’s say we are deep linking from just 5 main hosts, supporting at least 5 different domains/subdomains, both http and https, with many dynamic path variations based on the type of the link. For example, you URL might contain a country code, language code, etc… anything! In my use case, this list eventually ended up with <strong>~500</strong> &lt;/data&gt; entries in the Manifest. <br>I need to have a solution to manage this!</p><h4><strong>What is the solution?</strong></h4><p>Basically, the idea is to dynamically build the intent-filter and inject this in the AndroidManifest.xml.</p><p>I was looking for a way to generate these intent filters at build time and I ran into this <a href="https://github.com/castorflex/manifestreplace-plugin">https://github.com/castorflex/manifestreplace-plugin</a>.</p><p>To inject anything in the AndroidManifest.xml we can use the manifestPlaceholder functionality provided by the Gradle android-plugin, which exactly allows us to inject anything we want into the manifest. We will modify our build.gradle file accordingly.</p><p>But first, our manifest will look like something like that:</p><pre>&lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot;/&gt;</pre><pre>        ${deepLinks_manifestPlaceholder}</pre><pre>&lt;/intent-filter&gt;</pre><p>where ${deepLinks_manifestPlaceholder will be the key which will be replaced later with an intent-filter definition.</p><p>In your build.grade file, placeholders are set up as an array of key-value pairs. For our case, we only have one pair where the key is the placeholder defined in the manifest and the value is the result of a function generateData() which builds our intent-filter.</p><p>We place it in the defaultConfig block because we want this to be applied to any build type or flavor. You can also change this behavior based on your needs.</p><pre>android {<br><br>    defaultConfig {<br>        manifestPlaceholders = [deepLinks_manifestPlaceholder: generateData()]<br>    }<br>}</pre><p>Now we need to implement our function which will generate our injectable collection of &lt;data&gt; as a string, like you would do it if it was a manifest file, but this time it is done at build time using a Gradle script.</p><p>Let’s keep it simple just for the purpose of this article. You can have something like that, which will generate both http and https &lt;data&gt; providing a host and a path for each entry you want to add.</p><pre>static def generateData() {<br>    return <em>data(&quot;www.example.com, &quot;path_example_1&quot;) +<br>           data(&quot;m.example.com, &quot;path1&quot;) +          <br>           data(&quot;www.example.com, &quot;path_example_2&quot;) +<br>           data(&quot;m.example.com, &quot;path_example_3&quot;)</em></pre><pre>}</pre><pre>static def data(String host, String path) {<br>    return <em>http</em>(host, path) + <em>https</em>(host, path)<br>}<br><br>static def http(String host, String path) {<br>    return &quot;\n&quot; +<br>            &quot;               &lt;data\n&quot; +<br>            &quot;                   android:host=\&quot;$host\&quot;\n&quot; +<br>            &quot;                   android:pathPattern=\&quot;$path\&quot;\n&quot; +<br>            &quot;                   android:scheme=\&quot;http\&quot;/&gt;\n&quot;<br>}<br><br>static def https(String host, String path) {<br>    return &quot;\n&quot; +<br>            &quot;               &lt;data\n&quot; +<br>            &quot;                   android:host=\&quot;$host\&quot;\n&quot; +<br>            &quot;                   android:pathPattern=\&quot;$path\&quot;\n&quot; +<br>            &quot;                   android:scheme=\&quot;https\&quot;/&gt;\n&quot;<br>}</pre><p>It would be much better to extract this to a separate Gradle file to keep everything well organized.</p><p>We have not finished yet…. when will this bit be generated and injected in the manifest? Good question!</p><p>We need to add one more step to the processManifest gradle task to do the job for us. Let’s have a look.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e98d6331565b73d9446a510807a53dff/href">https://medium.com/media/e98d6331565b73d9446a510807a53dff/href</a></iframe><p>and here we are as a result of your Gradle build you will see your auto-generated AndroidManifest.xml under:</p><p>&lt;your_project_folder&gt;/build/intermidiates/manifests/full/&lt;your_flavor&gt;/&lt;your_build_type/AndroidManifest.xml</p><p>Enjoy!</p><p><em>References: </em><a href="http://antoine-merle.com/">Antoine Merle</a> on <a href="https://github.com/castorflex">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d441143cec7e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/how-to-manage-a-complex-deeplinks-scheme-on-your-android-app-d441143cec7e">How to manage a complex DeepLinks scheme on your Android App</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>