<?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 Vikas Bajpayee on Medium]]></title>
        <description><![CDATA[Stories by Vikas Bajpayee on Medium]]></description>
        <link>https://medium.com/@vikas.bajpayee?source=rss-c3f7354c81b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*tkZcm1bMD6hGKEUIiDDfOg.jpeg</url>
            <title>Stories by Vikas Bajpayee on Medium</title>
            <link>https://medium.com/@vikas.bajpayee?source=rss-c3f7354c81b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:59:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vikas.bajpayee/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android app with coroutines, flow, dagger, Stateflows with MVP architecture]]></title>
            <link>https://medium.com/bootcampers/android-app-with-coroutines-flow-dagger-stateflows-with-mvp-architecture-17114bb38c2b?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/17114bb38c2b</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mvp-architecture]]></category>
            <category><![CDATA[flow]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Sun, 16 Jan 2022 13:55:01 GMT</pubDate>
            <atom:updated>2022-01-17T03:14:50.548Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I will talk about how we can create a simple app that will list movies from this <a href="https://api.themoviedb.org/3/discover/movie?api_key=a427cfb730b4a73e67c646d8b44dd216">api</a> using coroutine, flow by following MVP architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*K8F6a8xbXTui9uCqRD-AaQ.gif" /><figcaption>App shows movies list in recyclerview</figcaption></figure><p>First of all, let&#39;s add the required dependencies for dagger, coroutines, etc. so our app’s level build.gradle will look like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e412e5d1b8284df1f1eee0eefae32eac/href">https://medium.com/media/e412e5d1b8284df1f1eee0eefae32eac/href</a></iframe><p>Now we have to create layout files, one is for movie listing, one is for mainview which can hold error view, loading view, movie listing layout in it,</p><blockquote>our activity_main.xml will look like this</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1aa2cb583a69ca06debd0e46249e64dc/href">https://medium.com/media/1aa2cb583a69ca06debd0e46249e64dc/href</a></iframe><blockquote>movie_item.xml</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9ee30e83e9db939c94509e250acaee8/href">https://medium.com/media/e9ee30e83e9db939c94509e250acaee8/href</a></iframe><blockquote>movie_list.xml</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5873235602508abfc85b8aef33ddca51/href">https://medium.com/media/5873235602508abfc85b8aef33ddca51/href</a></iframe><p>I will use TMDB API for listing movies from their site,</p><p><a href="https://www.themoviedb.org/documentation/api">API Overview - The Movie Database (TMDB)</a></p><p>Now let’s get into the details of the project structure, our project structure will look like this:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HtA6Rypbdn5G3a9DgLqnpw.png" /></figure><ol><li>So here, we have one API interface which holds suspend method to get the movie list.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmCK5d-iaO-EgGGLdKj74A.png" /></figure><p>2. Next, we are using dagger for dependency injection here, we have created one component that will provide app-level dependencies like retrofit, okhttpclient etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1abcbddf6952058062c41fdfec4d3f43/href">https://medium.com/media/1abcbddf6952058062c41fdfec4d3f43/href</a></iframe><p>and one subcomponent that will provide activity level dependencies.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d70b77f487eabbb0ba4013727bf34def/href">https://medium.com/media/d70b77f487eabbb0ba4013727bf34def/href</a></iframe><p>3. As we are following mvp architecture, so now we’ll have one <a href="https://github.com/vikasmain/MvpWithCoroutinesFlow/blob/main/app/src/main/java/com/app/coroutinesmvp/model/MovieModel.kt">MovieModel</a> that will hold the API call for getting the movie list.</p><p>4. Now, we will have one Presenter that will handle API call for movie list it will launch various views on the basis of api response. it is also observing Stateflow for handling click of movie item,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a38853f89f0c78deeb442337f3af770/href">https://medium.com/media/4a38853f89f0c78deeb442337f3af770/href</a></iframe><p>a) So here, we have one method onAttach() that will call by our mainActivity in onCreate() method, that method handles API call for getting movie list.</p><p>b) In <strong>callMovieApi()</strong> method if API get succeeds we will show movie listview(onEach block), if API failed(catch block) we will show error view, for loading state(onStart block), we will show loading view.</p><p>c) Next in <strong>observeOnClickStateFlow()</strong> we are observing the click state of movie item using stateflow, we will show the toast message on clicking on movie item.</p><p>so that’s it for this part. we will see how we can write tests for coroutine flows in <a href="https://medium.com/@vikas.bajpayee/how-can-we-write-tests-for-coroutine-flows-and-stateflow-in-kotlin-197616d4528f">next part</a>.</p><p>You can find the complete <strong>source code</strong> for this here:-</p><p><a href="https://github.com/vikasmain/MvpWithCoroutinesFlow">GitHub - vikasmain/MvpWithCoroutinesFlow: Movie listing app which shows movies from tmdb api</a></p><p>If you have any doubt related to this article please feel free to add comment here on contact me on <a href="https://www.linkedin.com/in/vikas-bajpayee-4a17aa106/">linkedin</a>.</p><p>Thank you for readig this article, if you liked it please feel free to share it with your friends too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17114bb38c2b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bootcampers/android-app-with-coroutines-flow-dagger-stateflows-with-mvp-architecture-17114bb38c2b">Android app with coroutines, flow, dagger, Stateflows with MVP architecture</a> was originally published in <a href="https://medium.com/bootcampers">Bootcampers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How can we write tests for Flows and Stateflow in Kotlin]]></title>
            <link>https://towardsdev.com/how-can-we-write-tests-for-coroutine-flows-and-stateflow-in-kotlin-197616d4528f?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/197616d4528f</guid>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[flow]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Sun, 16 Jan 2022 13:51:37 GMT</pubDate>
            <atom:updated>2023-03-01T03:17:11.074Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog I will talk about how we can write tests for coroutine flows, this blog is a continuation of the previous <a href="https://medium.com/p/17114bb38c2b">blog</a>, if you haven’t checked that out, please go through it.</p><p>So, we will write tests in this blog for suspending methods and coroutines flow methods. Before reading this blog you should have a basic understanding of how we can write JUnit tests in android.</p><p>If you have seen my previous blog you can see I have created one model class for handling API calls.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bc611323c70cc1351ff2fbfd6b7ddb7/href">https://medium.com/media/3bc611323c70cc1351ff2fbfd6b7ddb7/href</a></iframe><p>and our MovieApi class holds suspend method</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e1286871dbae8fb228a76be3e3e87d4/href">https://medium.com/media/9e1286871dbae8fb228a76be3e3e87d4/href</a></iframe><p>So our test class for this model will look like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1134a18ca677f1f178f76a82c9ff42f3/href">https://medium.com/media/1134a18ca677f1f178f76a82c9ff42f3/href</a></iframe><p>Let’s into the details of how we are testing the coroutine suspend method here in this class.</p><ol><li>So we have added runBlocking block here, it is a coroutine builder that separates the coroutine block with non-coroutine world, as suspend method can only be called from coroutine scope, so this method will create a coroutine scope and inside it, we can call the suspend methods(which we want to test). We are stubbing our suspend method <strong>api.getMoviesList() </strong>here to return a particular value.</li><li>Next, we are calling our model’s <strong>callMoviesApi() </strong>method that will return movies list, we are collecting the returned data of this method using a suspend method called collect, collect is a suspend method that collect the given flow, so as we know flows are cold in kotlin so they will start emitting data only when someone ask(or collect) it, so that’s why we have to use terminal operator here called collect. it will collect that data emitted from flow.</li><li>Now, as we have data from flow we can easily verify with our expected data using assertEquals(TestMovieData.getMovieData(), it)</li></ol><pre><strong>fun </strong>getMovieData(): MovieListResponse {<br>    <strong>return </strong>MovieListResponse(<br>        <em>listOf</em>(<br>            MovieListResponse.MovieListResult(<br>                backDropPath = <strong>&quot;&quot;</strong>,<br>                title = <strong>&quot;Spider man&quot;</strong>,<br>                releaseDate = <strong>&quot;26 oct 2019&quot;</strong>,<br>                voteAverage = 4.5,<br>                originalTitle = <strong>&quot;Spider man: The man&quot;</strong>,<br>                overview = <strong>&quot;Nice movie&quot;<br>            </strong>)<br>        )<br>    )<br>}</pre><p>4. For testing Api Failed usecase, we have a method called <strong>testApiFailed(), </strong>here also we are first stubbing <strong>api.getMovieList()</strong> but this time we are throwing error from this method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-VmPPr_SGoKf70DCKE5EA.png" /></figure><p>5. In the catch block, we are testing whether we are getting the null pointer exception message which we threw using stubbing above or not, if that passed then we are testing the correct thing here.</p><p>6. At the end, we have terminal operator collect just like above to collect flow, and here we are testing whether null is returned or not.</p><p>Now, we will see how we can test various flows methods (onStart, catch, onEach) in the presenter, here we will test how we can verify whether various views methods are calling or not correctly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e87dd5170926732f3f811a24b5c3ea38/href">https://medium.com/media/e87dd5170926732f3f811a24b5c3ea38/href</a></iframe><p>our test class for this method will look like this,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7cff1ac7c36e4575758f045d4d89bda/href">https://medium.com/media/c7cff1ac7c36e4575758f045d4d89bda/href</a></iframe><ol><li>Here we have created a coroutine scope like this:-</li></ol><blockquote>val scope = MainScope() + MainDispatchers.Unconfined(CoroutineContext)</blockquote><p>so, here we have combined scope with coroutine context- Unconfined(which is used to determine on which thread our coroutine will run),</p><p><strong>Two things to notice here:-</strong></p><p>a) As we know that we can’t get <strong>Looper.getMainLooper()</strong> on the testing environment, so we must have to add any context with MainScope() otherwise this will not work.</p><p>b) Next is we have used here Dispatchers.Unconfined here, so this dispatcher basically executes initial continuation of the coroutine in the current call frame and lets the coroutine resume whatever thread previously it is. that’s what we actually want because in test we don’t want to switch between threads here and want to do everything in the same thread.</p><p>So, now we are all sorted with coroutine scope and context creation part here,</p><p>2. Next is, we have created one instance of MoviePresenter here(which we want to test).</p><p>3. Then, We are testing API succeeds use case and checking whether the movie list is shown or not when API call succeeds. As our model method <strong>callMovieApi</strong> returns a flow so we have to create stubbing of that model method first and return movie data from it.</p><p>4. Next, we can test whether <strong>showLoadingView</strong>(), <strong>showMovieList</strong>(), <strong>hideLoadingView</strong>() methods are calling or not, because here we are returning response successfully by stubbing our API so our control will go to onStart{}, onEach{}, onCompletion{} block here. onStart{} and onCompletion{} will always be called.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1c5a734f8cc55a3f58f6761cc660ade/href">https://medium.com/media/d1c5a734f8cc55a3f58f6761cc660ade/href</a></iframe><p>Next, we will test <strong>API failed use case</strong>. So here if we don&#39;t return anything by stubbing model then it will automatically go to catch block of callMovieApi() method(because it will throw null here). from there we can test showErrorView() method is called or not.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a96cca137659c88d5119c934827c4a7/href">https://medium.com/media/8a96cca137659c88d5119c934827c4a7/href</a></iframe><p>Next, we are testing out <strong>state flows</strong> here.</p><p>So here, first we have passed value in onClickStateFlow and then called method where we are observing onClickStateFlow, now as we have passed value to our Stateflow so it will automatically go to <strong>OnEach{}</strong> block of our defined Stateflow and will show Toast view.</p><p>So, that’s it&#39;s for this part, if you want to check out the <strong>source code</strong>, You can check out the full source code here:-</p><p><a href="https://github.com/vikasmain/MvpWithCoroutinesFlow">GitHub - vikasmain/MvpWithCoroutinesFlow: Movie listing app which shows movies from tmdb api</a></p><p>If you have any doubt please reach out to me in the comments or contact me on <a href="https://www.linkedin.com/in/vikas-bajpayee-4a17aa106/">LinkedIn</a>. Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=197616d4528f" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/how-can-we-write-tests-for-coroutine-flows-and-stateflow-in-kotlin-197616d4528f">How can we write tests for Flows and Stateflow in Kotlin</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</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 make a string formatting server-driven in kotlin- Android?]]></title>
            <link>https://medium.com/geekculture/how-to-make-server-driven-string-in-kotlin-android-9ddd18b3d88d?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ddd18b3d88d</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[string]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[spannable-string]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 10:22:18 GMT</pubDate>
            <atom:updated>2022-03-21T09:42:52.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Let&#39;s suppose we want to change the color of a string on the basis of backend response in kotlin, and want to make some words of a string URL that will redirect to a webpage on click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EGnm2PVgSLZYfmMKA9ttfw.jpeg" /></figure><p>Let&#39;s suppose we want to achieve something like this ^, where you can see some text has links and some in bold(eg:- Detail), now also this whole string is coming from backend, <br>lets suppose our response is like this:-</p><pre>{<br>  &quot;string&quot;: &quot;Read more about %s and %s in $&quot;,<br>  &quot;text&quot;: [<br>    {<br>      &quot;title&quot;: &quot;TnC&quot;,<br>      &quot;href&quot;: &quot;<a href="https://www.google.com/">https://www.google.com</a>&quot;<br>    },<br>    {<br>      &quot;title&quot;: &quot;Product Information&quot;,<br>      &quot;href&quot;: &quot;<a href="https://www.linkedin.com/">https://www.linkedin.com</a>&quot;<br>    },<br>    {<br>      &quot;title&quot;: &quot;Detail&quot;,<br>      &quot;href&quot;: null<br>    }<br>  ]<br>}</pre><p>if you see our backend response we have given some special characters for strings that we want to change or do formatting on those strings on local and we also created one array of text which will contain the title and link’s href, so that we can make some words clickable in strings and open a webpage after click on it, if href is null we will assume that we have to that word as bold in string. you guys can make a response according to your requirement I just gave an example how we can achieve this using special characters in our string.</p><p>Its time to write the frontend kotlin code ✌️</p><pre><strong>val </strong>footerString = SpannableStringBuilder(<strong>&quot;Read more about %s and %s in $&quot;</strong>)<br>addFormattingToFooterString(footerString, footer)<br><br><em>with</em>(<strong>binding</strong>.contentView.tvTermsAndConditions) <strong>{<br>    </strong><em>text </em>= footerString<br>    <em>linksClickable </em>= <strong>true<br>    </strong><em>movementMethod </em>= LinkMovementMethod.getInstance()<br><strong>}</strong></pre><p>As you can see in the above code we have created one spannable string, spannable strings are useful when we want to add some styles or some spans to some specific words in our string. <br>After that we called add formatting to string method to add styling and links to the string.<br>below that we made our whole textview clickable and added link movement so whenever any we add any href(url) to any word in our string, after click on it, that will open the respective web page.</p><pre><strong>private fun </strong>addFormattingToFooterString(<br>    footerString: SpannableStringBuilder,<br>    footer: Footer<br>) {<br>    <strong>var </strong>linkListIndex = 0<br>    footerString.<em>forEachIndexed </em><strong>{ </strong>index, char <strong>-&gt;<br>        if</strong>(char == <strong>&#39;$&#39;</strong>){<br>            footerString.setSpan(<br>                StyleSpan(Typeface.<em>BOLD</em>),<br>                index, index+1, Spannable.<em>SPAN_INCLUSIVE_INCLUSIVE<br>            </em>)<br>            footerString.replace(index, index+1, <strong>&quot;Detail&quot;</strong>)<br>            linkListIndex++</pre><pre>        }<br>        <strong>if </strong>(char == <strong>&#39;%&#39;</strong>) {<br>            footerString.setSpan(<br>                StyleSpan(Typeface.<em>BOLD</em>),<br>                index,<br>                index + 2,<br>                Spannable.<em>SPAN_INCLUSIVE_INCLUSIVE<br>            </em>)<br>            <strong>val </strong>footerTermsAndConditionString = footer.<strong>link</strong>[linkListIndex].<strong>text<br>            val </strong>replaceableString =<br>                <strong>&quot;&lt;a href=&#39;&quot; </strong>+ footer.<strong>link</strong>[linkListIndex].<strong>url </strong>+ <strong>&quot;&#39;&gt;&lt;u&gt;$</strong>footerTermsAndConditionString<strong>&lt;/u&gt;&lt;/a&gt;&quot;<br>            </strong>footerString.replace(<br>                index,<br>                index + 2,<br>                <strong>if </strong>(Build.VERSION.<em>SDK_INT </em>&gt;= Build.VERSION_CODES.<em>N</em>) {<br>                    Html.fromHtml(replaceableString, Html.<em>FROM_HTML_MODE_LEGACY</em>)<br>                } <strong>else </strong>{<br>                    Html.fromHtml(replaceableString)<br>                }<br>            )<br>            linkListIndex++<br>        }<br>    <strong>}<br></strong>}</pre><p>In the above method, we did multiple things let&#39;s understand all these things one by one.<br>1. first we created one listIndex variable for getting the index of title in the above-created text array(in backend response).</p><p>2. lets traverse our footerString and let&#39;s check for a bold string using $ character, if it&#39;s present in the response string, we will replace it with a backend string and will make it bold. for this first, we will set the span for this and will make the string bold between current index and current index+1(because we only want to replace word whose length is 1 right now(current index+1-currentIndex, `$`).</p><p>3. Now after this we replaced the character with our word which we want to make bold using backend response. now as we have used <strong>SPAN_INCLUSIVE_INCLUSIVE</strong> here, so this span will expand to include any newly inserted characters in the string and will make them bold also, its definition according to the documentation is:-</p><pre><em>/**<br> * Spans of type SPAN_INCLUSIVE_INCLUSIVE expand<br> * to include text inserted at either their starting or ending point.<br> */</em></pre><p>4. Now next is we add urls to words with %s and replaced %s with text coming in backend response and add urls to them. as we have already maintained a list index variable to find the index of the replaced string in text array, we will use it as a replaced string.</p><p>5. Now we are using href’s anchor tag to add the URL to the specific word.</p><p>6. At the end we will replace our %s with Html string and it&#39;s done.</p><p>So, as you guys can see how we designed our backend contract to make things like styling, URLs to words in string backend driven. this has so many benefits that in the future we can change as many words (change their styles, add urls to some words) on the front end without any app release.<br>We can also use <a href="https://developer.android.com/reference/android/text/style/ClickableSpan">ClickableSpan</a> for our use case, but it creates some extra classes and also some extra code, so I went with this.</p><p>Thank you for reading this article, if you have any doubt or feedback you can reach out to me on <a href="https://www.linkedin.com/in/vikas-bajpayee-4a17aa106/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ddd18b3d88d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-make-server-driven-string-in-kotlin-android-9ddd18b3d88d">How to make a string formatting server-driven in kotlin- Android?</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean architecture Android— important points and terms]]></title>
            <link>https://medium.com/@vikas.bajpayee/clean-architecture-android-important-points-and-terms-23272265e262?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/23272265e262</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[presenter]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 14:23:55 GMT</pubDate>
            <atom:updated>2023-09-11T05:35:28.229Z</atom:updated>
            <content:encoded><![CDATA[<p>Everyone wants to follow clean architecture principles for their android project, but following clean architecture principle is not that easy with large projects and if you want to follow architecture principles correctly then there are some fancy terms which you have to use while building your project. These terms look fancy but they help a lot while building your own big project because in big projects if you start naming files according to your thinking skills then it will be pretty hard for new developers to understand the code early. that’s why there are some terms and topics which are specifically designed for big projects which help in defining the file names better and most of the developers follow them, so it is important to understand these terms and topics clearly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*oV_UWJHwVuQuOXh9kVllQw.png" /><figcaption>Circles represent different levels of software in your app</figcaption></figure><p><strong>How clean architecture works?</strong></p><p><strong>Repositories</strong> get data from entities(which can be from the server, local etc), <strong>use-case</strong> has references of multiple repositories, now <strong>use case</strong> applies business logic on data fetched from multiple repositories, the <strong>presenter</strong> has the reference of multiple use-cases, <strong>presenter</strong> provides coordination between multiple use-cases and then it presents data to the UI, a presenter can also handle UI logic too.</p><p><strong>Some important terms<br></strong>1. <strong>Presenter</strong> — It acts as a middleware between UI and data layer, it takes data from the data layer and presents it to the UI. It contains multiple use-cases and handles the interaction between those use-cases. it also converts data layer model into the UI layer model.</p><p>2. <strong>Delegate</strong> — delegate works as a helper for a presenter. if a presenter getting two big( difficult to read), then delegate comes as a helping hand for the presenter, for example, let’s suppose you have a logic in your app which handles all the listeners and these listeners take required actions for buttons, now you can move this logic inside the delegate. Delegate is a class that is wrapping up the actual call. We use delegates so that internal class if replaced doesn’t make any difference for the outside world.</p><p>for ex: if we replace view reference then class Using <strong>ViewDelegate</strong> will not be affected.</p><p>3. <strong>UseCase</strong> — A use case handles the business logic for a project. It combines data from multiple repositories and gives it to the presenter.</p><p>4. <strong>Formatter</strong> — it is used to format the data for display on screens, example if you want to display prices on-screen with currency code then you have to create a method in this class and that will return formatted data. if it’s a UI formatter it can have activity class reference too.</p><p>5. <strong>Repository</strong> — Repositories are responsible to coordinate data from the different Data Sources. This Data Layer depends on the Domain Layer. Repository takes data from different entities and gives it to the use-cases.</p><p>6. <strong>Entity</strong> — simple POJO classes that are business data models or objects.</p><p>7. <strong>Handler</strong> — A handler is not a correct term, it can do complex(multiple) things, for example :- error handling for a usecase.</p><p>8. <strong>Helper</strong> — A Helper is created when we wanted to do something again and again. This class also used to assist in providing some functionalities, which is not the main goal of a class.</p><p>9. <strong>Interactor</strong> — Basically interactor is a part of MVP architecture, but as it works like a usecase so sometimes people use it in clean architecture too. Basically it manipulates different entities just like a use-case and provides support to a presenter so that business logic and manipulating the UI logic can be separated out easily.</p><p><strong>Example to Understand clean architecture:-<br></strong>Let’s suppose there is an application which fetches data of different cricket players and the user has to login first to view that data. so the flow of app will look like this:-<br>User login -&gt; if successful -&gt; then show players data(fetched from an API).</p><p>Let’s decode how different classes and structure will look like here if we follow clean architecture here:-<br><strong>Players.kt(Entity)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8b41f39d3a8b40069fbfa9fea097647/href">https://medium.com/media/d8b41f39d3a8b40069fbfa9fea097647/href</a></iframe><p><strong>PlayersRepository.kt(Repository)<br></strong>we will have a repository that will fetch players list from an API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/376bea55353ff0dfe47b2573a3c0c578/href">https://medium.com/media/376bea55353ff0dfe47b2573a3c0c578/href</a></iframe><p><strong>LoginRepository.kt(Repository)<br></strong>we will have a login repository too which will check whether user is logged in or not, we will send emailId and username in api request and then if user is found in the database then we will return success as status in api response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8e384268de549bd54025ca49f4153ce/href">https://medium.com/media/d8e384268de549bd54025ca49f4153ce/href</a></iframe><p><a href="https://gist.github.com/vikashumain/9457e37318f203200af6523adb3df803"><strong>PlayersUseCase.kt</strong><br></a>This use-case will handle references of these two above created repositories and will provide data to the presenter, basically, it will first check whether the user is logged in using loginrespository and then it will get data from playersrepository. So playersUseCase is manipulating(playing) the data fetched from multiple repositories here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6072ccfb154fbd5b4ffb758e22bde838/href">https://medium.com/media/6072ccfb154fbd5b4ffb758e22bde838/href</a></iframe><p><strong>PlayersPresenter.kt<br></strong>This class will present data obtained from playersusecase to the UI, now this will also have a function called addPrefixToPersonName() which will have a functionality of adding Mr to the male player and Mrs to the Female Player(Ui manipulating). now all this data will give to the Activity or Fragment which can simply show this on layouts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e1d02aadba774f7920506707398af16/href">https://medium.com/media/6e1d02aadba774f7920506707398af16/href</a></iframe><p>So, the above example shows how clean architecture works.</p><p><strong>Some Small things which we should remember while coding large projects:-<br></strong>1. A View can’t have a reference of analytics events, because analytics is business logic and view shouldn’t have those. analytics should be inside use cases because analytics are part of domain layer.<br>2. Remote Configs(Firebase etc) logic should be inside presenter.<br>3. A use case can have references of multiple repositories but a repository can’t have references of any use-case.<br>4. A presenter can have references of multiple use-cases because presenter can also provide coordination between multiple use-cases.<br>5. Most of the times an entity(DAO) is not a business object, but repository is used by business layer and it returns a business object.<br>6. A use-case can have references for one or two Handlers.<br>7. A use-case shouldn’t hold references of other usecases, because it would break the SRP principle for a usecase and also our unit tests will be more fragile in that case.</p><p>8. A use-case shouldn’t have reference of any view, because usecase only represents domain layer(fetches data from the repository), only presenter should have view reference. It is only for holding complex logics.</p><p>9. Clean architecture is good only for large projects because one pitfall of clean architecture for small projects is that:- it creates too many unnecessary classes in small projects Which are just for achieving a clean architecture concept. So, if you have small projects, please go with other architectures. 🙏</p><p>Thank you for reading this article, if you have any doubt or feedback you can reach out to me on <a href="https://www.linkedin.com/in/vikas-bajpayee-4a17aa106/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23272265e262" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Process vs Task]]></title>
            <link>https://medium.com/@vikas.bajpayee/process-vs-task-53bbee024d33?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/53bbee024d33</guid>
            <category><![CDATA[backstack]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[process]]></category>
            <category><![CDATA[tasks]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Fri, 29 May 2020 06:32:08 GMT</pubDate>
            <atom:updated>2020-05-29T06:32:08.893Z</atom:updated>
            <content:encoded><![CDATA[<p>Everyone in Android discusses Task but no one discusses about what is a process, in this blog I am going to explain what is the basic difference between a task and process. before that let us first understand what is a Task and backStack in android.</p><h3>Task</h3><p>A task is a collection of activities(screens), now these activities can be of different applications or from the same application. Activities of different applications invoked by the intent are put into the same Task.</p><h3>BackStack</h3><p>A Task contains multiple Activities and these activities arranged in a Stack called Back Stack. This Stack has LIFO structure and it stores the activities in the order of their opening. <strong>The Activities in the Stack are never rearranged</strong>.</p><p>Activity’s Manifest attributes related to back stack:-</p><ol><li><strong><em>noHistory</em></strong> - If this is set to true then it destroys the current Activity and removes it from the back stack whenever any other Activity is started by it. You don’t have to explicitly call finish for this activity. this attribute is effective in SplashActivity.</li><li><strong><em>clearTaskOnLaunch</em></strong> - If this attribute is set to &quot;true&quot; in the root activity of a task, the stack is cleared down to the root activity whenever the user leaves the task and returns to it. In other words, it&#39;s the opposite of alwaysRetainTaskState. The user always returns to the task in its initial state, even after leaving the task for only a moment.</li><li><strong><em>finishTaskOnLaunch</em></strong> - This attribute is like clearTaskOnLaunch, but it operates on a single activity, not an entire task. It can also cause any activity to go away, including the root activity. When it&#39;s set to &quot;true&quot;, the activity remains part of the task only for the current session. If the user leaves and then returns to the task, it is no longer present.</li><li><strong><em>alwaysRetainTaskState</em></strong> - If this attribute is set to &quot;true&quot; in the root activity of a task, the default behaviour just described does not happen. The task retains all activities in its stack even after a long period.</li></ol><p>Example for the above attributes can check out here:-<br><a href="https://stackoverflow.com/questions/22309876/relationship-between-androidnohistory-and-androidfinishontasklaunch">https://stackoverflow.com/questions/22309876/relationship-between-androidnohistory-and-androidfinishontasklaunch</a></p><p>Now let’s dig deeper to understand the difference between process and task</p><h3>Processes vs Task</h3><p><strong>Task</strong> — A task is a collection of activities that users interact with when performing a certain job. The activities are arranged in a stack (the “back stack”), in the order in which each activity is opened. An activity can even start activities that exist in other applications on the device. For example, if your application wants to send an email, you can define an intent to perform a “send” action and include some data, such as an email address and a message. An activity from another application that declares itself to handle this kind of intent then opens. In this case, the intent is to send an email, so an email application’s “compose” activity starts (if multiple activities support the same intent, then the system lets the user select which one to use). When the email is sent, your activity resumes and it seems as if the email activity was part of your application. Even though the activities may be from different applications, Android maintains this seamless user experience by keeping both activities in the same task.</p><p><strong>Process</strong> — When an application component starts and the application does not have any other components running, the Android system starts a new Linux process for the application with a single thread of execution. By default, all components of the same application run in the same process and thread (called the “main” thread). Every application runs in its own process and all components of the application run in that process, by default.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53bbee024d33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OK Google, Meet Gojek]]></title>
            <link>https://medium.com/gojekengineering/ok-google-meet-gojek-50207dacf444?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/50207dacf444</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gojek]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Fri, 17 Jan 2020 04:16:51 GMT</pubDate>
            <atom:updated>2020-01-17T04:16:51.082Z</atom:updated>
            <content:encoded><![CDATA[<h4>We added Gojek’s ride-hailing and food ordering functions to Google Assistant. Here’s what we learned in the process.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QaQg1VnVWuhAebytXO-gKg.jpeg" /><figcaption><a href="http://bit.ly/30urSRM">gojek.jobs</a></figcaption></figure><p><strong>By Vikas Bajpayee and Lokesh Kalal</strong></p><p>Our aim behind building a Super App was to help our users get rid of the daily frictions in their lives. But the journey doesn’t stop there. Even after building all these convenient products, we still try and reduce frictions that may be encountered even within our app — such as booking a ride or ordering food.</p><p>So we thought, why don’t we integrate with Google Assistant, and let our users communicate with our products in a new way?</p><p>In this post, we explain how we integrated our food and transport products with the Google Assistant.</p><h3>The why</h3><p>We’ve already addressed one part of the <em>why — </em>convenience. The other is user re-engagement. According to <a href="https://andrewchen.co/new-data-shows-why-losing-80-of-your-mobile-users-is-normal-and-that-the-best-apps-do-much-better/?utm_content=buffere4fa2&amp;utm_medium=twitter.com&amp;utm_source=social&amp;utm_campaign=buffer">this survey</a> conducted by Silicon Valley researcher Andrew Chen 77% of users stop using an app three days after they install it. Within a month, that number goes up to 90%. 👀</p><h3>The how</h3><p>To help integrate Android apps with the Google Assistant, Google launched App Actions:</p><h4>What are app actions?</h4><p>App Actions are a new way to make your android app content available in places like Google Search, Google Assistant etc. From a user’s perspective, App Actions behave like shortcuts to parts of your Android app. When users invoke an App Action, the Assistant either launches a screen in the Android app that the user has already installed or shows an embedded visual card (Android Slice) that users can interact with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*w4jk-CTME9amkb5dsIQDzw.gif" /></figure><p>App actions provide a faster way for users to access Android apps. It can be achieved in two ways:- either user can be directed to a specific activity(screen) using a deep link or user may see relevant content on the Assistant itself called Slices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*KPBLtVMjiHBOPEJ53E9F8A.gif" /></figure><p>More info on this can be found here: <a href="https://developers.google.com/assistant/app/overview">https://developers.google.com/assistant/app/overview</a></p><h4><strong>What are Slices?</strong></h4><p>Slices are super-powered app actions. They provide a way to interact with apps without moving away from Assistant by showing a small piece of UI within Assistant. Slices are UI templates that can display rich, dynamic, and interactive content from the app in Google Assistant.</p><blockquote>Slices can help users perform tasks faster by enabling engagement outside of the fullscreen app experience.</blockquote><p>You can build Slices as enhancements to App Actions.</p><p>Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnyLYHOf_qPDqf30D70SUA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*od8f2tGA3Rd6EQrjlgUuOw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFF30b3185UtwKYjx0VP1A.jpeg" /><figcaption>Check food order status on Gojek</figcaption></figure><p>We choose to use slices to show food order status, as the order status will have limited information (eg. Driver is on the way to Restaurant, with his location on Map ) which can be easily shown in a small piece of UI segment.</p><p>In fact, this functionality was recently demoed on stage at a Google event in Indonesia. You can check it out below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0u20Iu4m2Co%3Fstart%3D5805%26feature%3Doembed%26start%3D5805&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0u20Iu4m2Co&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0u20Iu4m2Co%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbb8bb508f8af1e5a89b4cd0abe6bbfd/href">https://medium.com/media/dbb8bb508f8af1e5a89b4cd0abe6bbfd/href</a></iframe><h3><strong>How does it work?</strong></h3><p>Whenever a user says or types something in Assistant, assistant parses the query. If the query matches the<a href="https://developers.google.com/assistant/app/reference/built-in-intents"> built-in intent</a> grammar then Google Assistant extracts the query parameter in<a href="https://schema.org/"> schema.org</a> and generates a deep link URL using the mapping we provide in an actions.xml file.</p><p>Google then attaches those extracted parameters to the deep link URL and creates a final deep link which allows a user to launch specific content or screens in the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jUlpzwbXbFIgGy7s" /><figcaption>App Action Flow <a href="https://developers.google.com/assistant/app/overview">(Source: Google)</a></figcaption></figure><p>Let’s dig a little deeper:</p><p>Google applies Machine Learning and Artificial Intelligence (Natural Language Processing) to understand all the sentences we type in Assistant.</p><p>While users can type anything they want in Assistant and the system gets better at interpreting them over time, but there are some sentences for specific intent that are fixed by Google. More info <a href="https://developers.google.com/assistant/app/reference/built-in-intents#create-taxi-reservation">here</a>.</p><h3><strong>How did we integrate our services with Assistant?</strong></h3><p>The core of integrating Gojek with Assistant involved creating actions on Google Assistant with actions.xml file.</p><p>Let’s explore how to do this:</p><p>1. Create <strong>actions.xml</strong> file in your XML folder. This contains all the actions with built-in intents which define what actions our app can support in the Assistant. Each action contains<a href="https://developers.google.com/assistant/app/reference/built-in-intents#create-taxi-reservation"> built-in intents</a> supported by Google as a &lt;intent-name&gt; tag.</p><p>2. Define a fulfilment mode for each app action — which can be deep links or slices. You have to pass a fulfilment mode in each action. This is compulsory.</p><p>3. Pass the URL template which will allow a user to launch your app — this can be the deep link to your app or URL to Slice provider.</p><p>4. Define entity-set — the Gojek app is available in multiple locales, so to provide locale for all the regions, we added the entity-set, which allows Assistant to understand more than one version of category. ex:- taxi can be pronounced as taksi in Bahasa.</p><p>So, If you want locale for your specific parameter in deep-link URL, you can simply attach an entity-set with that parameter, see how you can achieve this in below example</p><pre>&lt;parameter name=”taxiReservation.category”&gt;</pre><pre>&lt;entity-set-reference entitySetId=”TransportCategoryEntitySet” /&gt;</pre><pre>&lt;/parameter&gt;</pre><p>5. Add a reference to <strong>actions.xml</strong> file using the &lt;meta&gt; tag in your app’s manifest.xml file inside the application tag.</p><p><strong>In order to integrate Slices:</strong></p><ol><li>Implement an Android Slice by following the steps described in the <a href="https://developer.android.com/guide/slices/getting-started">Slices Getting Started guide</a>.</li><li>In the actions.xml file, in the &lt;fulfillment&gt; element, specify fulfillmentMode=“actions.fulfillment.SLICE” to indicate that a user intent can be fulfilled using a Slice in your app.</li></ol><h3><strong>A few quick notes on what we learnt</strong></h3><ol><li>Testing this feature is pretty hard and things become weird when you have multiple build types of your app. For testing, you need a build type on the Play Store, (which means the package name of the testing build should match the package name of the published app). You can use a plugin (developed by Google) called<a href="https://developers.google.com/assistant/app/test-tool"> <strong>App Actions Test Tool</strong></a> for testing this feature.</li></ol><blockquote>Please make sure you are following points while testing with App Actions Test Tool:<br> a) Log in to Android Studio and Google Assistant with the account which has access to your published app on Play console.<br> b) ApplicationId of the app should be the same as your published app.<br> c) Your Gradle should be built successfully.<br> d) Use App Action Tool to create and update preview and test the app actions and slice.</blockquote><p>2. If your app is used in different locales, you can create locales using <a href="https://developers.google.com/assistant/app/action-schema#entity-set-reference">entity-set</a> in the actions.xml file.</p><p>3. In order to give early builds to QA or other users (if you have multiple build types in your app), you can create an internal test track on Play console and add relevant people to it. This allows you to share the build to production for only some listed users.</p><p>(See <a href="https://support.google.com/googleplay/android-developer/answer/3131213?hl=en">this</a> for how you can create an internal test track for your app.)</p><p>4. Actions.xml shouldn’t be <strong>obfuscated</strong> in release apk — it means if you are using any obfuscated tools like proguard then actions.xml shouldn’t be obfuscated there.</p><p>5. Slices can be requested before the onCreate of your application is completed. You can run into issues if you are using something which is initialised in onCreate while creating slices.</p><p>6. Don&#39;t refresh slices from onBindSlice() method, it will end up in an infinite loop where Google Assistant will call onBindSlice() infinitely.</p><p>That’s all from us folks. Hope this post gave you a better understanding of how App Actions and Slices work with Google Assistant. Working on this feature was an amazing experience for us. If you use the Gojek app, make sure to give them a try and let us know what you think. 🙌</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yigf1nGxRKjzV7vIC_YkYg.png" /></figure><p>Liked what you read? <a href="https://mailchi.mp/go-jek/gojek-tech-newsletter">Sign up for our newsletter</a> and we’ll send you updates from the blog straight to your inbox! 🖖</p><figure><a href="http://bit.ly/30urSRM"><img alt="Gojek Job Openings" src="https://cdn-images-1.medium.com/max/803/1*XSAkmYAomyHp6_18rjjAfA.jpeg" /></a><figcaption>gojek.jobs</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50207dacf444" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gojekengineering/ok-google-meet-gojek-50207dacf444">OK Google, Meet Gojek</a> was originally published in <a href="https://medium.com/gojekengineering">Gojek Product + Tech</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 Start a Startup in India: Startup Basic terms]]></title>
            <link>https://medium.com/@vikas.bajpayee/how-to-start-a-startup-in-india-startup-basic-terms-9d56a0cbd26b?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d56a0cbd26b</guid>
            <category><![CDATA[startup-life]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[india]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Sat, 14 Sep 2019 15:33:37 GMT</pubDate>
            <atom:updated>2019-09-15T06:06:05.203Z</atom:updated>
            <content:encoded><![CDATA[<p>On the weekend I had a discussion with my college’s senior friend he just got funding from Sequoia India for its new Startup and we were discussing things how he got this and other kinds of stuff, then I asked him.</p><blockquote>What is Seed Capital?<br>Not only he helped me understand this but also emphasised on the fact that how important it is for one to be aware of such technical jargons and their meanings. “I learned these things during my B.Tech years”, he said.</blockquote><p>It was then that I realised I was missing something important. I started exploring these things and here I am with a list of some very basic terms that I think will be useful for you to know.</p><p>So first things first,</p><p><strong>What is a Startup?<br></strong>A startup is a newly established business, usually small, started by 1 or a group of individuals. What differentiates it from other new businesses is that a startup offers a new product or service that is not being given elsewhere in the same way. The keyword is <strong>innovation</strong>. The business either develops a new product/ service or redevelops a current product/service into something better.</p><p>The definition of a startup is very broad and unclear. but according to the creator of the <a href="https://www.startups.co/articles/lean-startup-methodology-can-help?__hstc=219066822.01f1f8653d328bbda82e917e3ffae4e4.1568471596879.1568471596879.1568471596879.1&amp;__hssc=219066822.1.1568471596879&amp;__hsfp=748686863">Lean Startup methodology:</a></p><blockquote>“A startup is a human institution designed to create a new product or service under conditions of extreme uncertainty.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*lFz7XgWPz4jYEjzBzjYgSg.jpeg" /></figure><p>So we have some knowledge about what is a startup, now let’s talk about some basic terms related to it.</p><p><strong>Terms Related to Startup</strong></p><ol><li><strong>Activation</strong> -It is a measurement of the conversion rate from when a prospective visitor becomes an active user on your website. This would result from a user experience that begins with the user downloading something or even signing up.</li><li><strong>Angel Investors</strong> -An angel investor is a high net worth individual who puts their own finance into the growth of a small business in the early stage as seed funds for debt or equity ownership. They invest in the formative stages of the startup’s business and usually start contributing funds when the startup has something to present, such as a prototype of the product or service.</li><li><strong>Equity</strong> -Equity essentially means ownership. Equity represents one’s percentage of ownership interest in a given company. For startup investors, this means the percentage of the company’s shares that a startup is willing to sell to investors for a specific amount of money. As a company makes business progress, new investors are typically willing to pay a larger price per share in subsequent rounds of funding, as the startup has already demonstrated its potential for success.</li><li><strong>Venture -</strong>A <strong>venture</strong> is any major undertaking or project that requires the risking of time and/or money.</li><li><strong>Business Venture</strong> -Start-up entity developed with the intent of profiting financially. A business venture may also be considered a small business. Many ventures will be invested in by one or more individuals or groups with the expectation of the business bringing in a financial gain for all backers. Most business ventures are created based on the demand of the market or a lack of supply in the market. Needs of consumers are identified for a product or service and the entrepreneur and investors will proceed to develop the idea, market the idea, and sell the product or service developed.</li><li><strong>Venture Capita</strong>l -Venture capital is a type of funding for a new or growing business. It usually comes from venture capital firms that specialize in building high-risk financial portfolios. With venture capital, the venture capital firm gives funding to the startup company in exchange for equity in the startup.</li><li><strong>Seed Capital</strong> -Seed capital is a form of securities offering that brings an investor to invest capital in exchange for an equity stake in a company. This usually takes place in the initial stages of the company.</li><li><strong>Pivot -</strong>A startup begins to pivot when they want to use their existing tech and resources for an entirely different process. This includes doing business in different market segments.</li><li><strong>Minimum Viable Product(MVP)</strong> -It is a low-cost lightweight prototype of a company’s product that is used to learn more about its potential to sell in the market. Companies use this strategy to decide before they start mass manufacturing the product.</li><li><strong>Growth Hacking</strong> -Growth hacking is where art and science meet business ideas that use a set of conventional and non-conventional marketing experiments that lead to the growth of a business. Growth hackers are marketers, engineers, and product managers who try new and improved ways to engage the user base of a business.</li><li><strong>Venture Capitalists</strong> -A venture capitalist is one who is part of a limited partnership who is investing in the startup in the form of venture capital funds. They enter in the later stages of development for a portion of equity or debt ownership in an effort to advance the growth of the company by developing its market share.</li><li><strong>Entrepreneur</strong> -Entrepreneurs just think and do things differently. … Being entrepreneurial can mean knowing your industry inside out, and being able to exploit that knowledge to create new opportunities. Being entrepreneurial can mean sharing ideas freely, and celebrating so-called failures as learning and growing experiences.</li><li><strong>Founder</strong> — Founder is a person who comes up with an idea and then transforms it into a business or startup. Founders can set up a business on their own, or they can do it with others.</li><li><strong>Series A, B, C rounds -</strong>These rounds take place in the developmental stages of a startup for the purpose of raising capital. Such rounds are based on the maturity level of the business, potential investors who take an interest, the purpose for raising capital, and how it is allocated. These rounds are vital steps that are required to turn a startup with a profitable idea into a successful global company.</li></ol><p>Series A rounds of funding are basically meant for the optimisation of the product or the user base of a certain startup. It builds on plans that aim at reaping long term capital to push a potential profit generating idea.</p><p>Series B rounds of funding are focused on advancing a business beyond the development stage by expanding the company’s market reach. At this stage, venture capitalists who are investing make a huge call on the business plans as they invest in the startups.</p><p>Series C rounds of funding aim at scaling up. There is a substantial inflow of capital to up the returns in case a startup is performing well. At this stage, several investors rooting for a certain startup contribute funds to tackle competitors; several acquisitions and acqui-hires take place.</p><p><em>Now, What’s the point of learning all the above things?</em></p><p><em>Knowledge of these terms will come handy for you if you ever get a chance to have a discussion with any entrepreneur or maybe when you think of starting your own Startup.</em></p><p>Okay, enough said on the terms but how about beginning with your own Startup ? Well, here is all you need to know.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*5IZO4HQaOdJnS-k9gcqh3Q.gif" /></figure><p>I’m going to discuss here some steps about it.<br>1. <strong>Idea</strong></p><p><em>The very first thing to start a startup is “IDEA”.</em></p><p>What are you going to start so that potential customers will pay for that?</p><p>Is there enough market for your idea?</p><p>2. <strong>Team or Co-Founder</strong></p><p>You can not do everything yourself in the startup so having a good initial team or a perfect partner is critical for startup success. Creating the initial team can be a tough job. First, you need to decide, who to hire? identify the core skills you need to take your startup to the next stage like a developer, sales, marketing and others depending upon the nature of your startup.</p><p>3. <strong>Legalize it</strong></p><p>Once you have the product/ service ready to sell to customers or an idea which needs to raise funding before creating a product or initial team. You need to have a legal identity or we say a company in India. There are different types of companies you can register in India but Private limited, LLP and partnership firms are most common.</p><p><em>You can read this full guide on </em><a href="https://bizztor.com/in/how-to-register-a-company-in-india/"><em>How to register a company in India here</em></a></p><p>4. <strong>Raising Funding</strong></p><p>To run the startup, you need money. The best way is to generate money through paying customers, start selling from day one. Create as much as positive impacts towards your’s investors, they are everything for you, you can’t do anything without money so find a right investor which suites best for your’s startup.</p><p>5. <strong>Secure Intellectual Property and Rights</strong></p><p>When you ask yourself how to start a startup, you also need to check if you can actually start or even own that startup.</p><p>For this, you need to secure intellectual property rights and research if they are already not patented or trademarked by someone else. Intellectual property or IP refers to the process by which you or your company can own the rights to create your product and then sell them. Examples or IP rights include patents, copyright, and trademarks and they are vital to your success and your company’s success in the future. It is important to secure your IP early on as it will protect you against any copycats. This will also let you know if you are not one of the “copycats” and that your product is genuine and not violating any existing IP rights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*fqu1IAZHjxv9hv0VcZzF3w.gif" /><figcaption>technical difficulty</figcaption></figure><h3><strong>Difficulties or challenges you might face while starting a startup in India</strong></h3><h4>“To be or not to be” — Procrastination</h4><p>Since start-up attracts the Newbies and given the uncertainties of such a ventures industry reputed hardly look them as an option. Therefore, most start-ups have to build and grow on non-specialist managers giving way to longer decision-making time and lost opportunities.</p><h4>Hitting the market without evaluating enough options</h4><p>Since research is a costly affair, the startup entrepreneurs have to jump into deciding on creating the MVP without checking it out to a broader set of audience. Not testing on larger consumer base can lead to lesser trails thereby reduced options.</p><h4>Talent insufficiency</h4><p>Although skilled personnel is not quite bad in India, start-ups just cannot afford them all the time. Often, however, the multi-skill required to make start-up success stories are very rare to find.</p><h4>Policy of Government</h4><p>India lacks a clear long-term start-up roadmap, as economic liberalization is quite new to India. Given the size of the nation and the priorities, the government seems to keep the road-map on the back burner.</p><h4>Not able to execute: 20% Idea and 80% Execution</h4><p>Success lies in skilful execution. Ideas can create a castle in the air, but the visionary has to take the blocks of brick to build the castle.</p><h4><strong>Insufficient information on marketing strategies</strong></h4><p>Lacking information in marketing systems. In India, each state is interested in culture, food, and customs, language, outfit, etc. So what is moving in Maharashtra like hotcakes may stay immaculate in Tamilnadu? An exhaustive learning of area insightful need and a down to earth advertise overview is of most extreme significance before venturing into the hazardous ocean of new companies. One ought to recollect each startup doesn’t create something as progressive as iPods. Marketing strategies go under this equivalent area too.</p><p>Some faqs, which will give u some extra knowledge.</p><p><em>1. What is the difference between a startup and a small business?</em></p><p>Small<strong> </strong>businesses are driven by profitability and stable long-term value, while startups are focused on top-end revenue and growth potential.</p><p>2. <em>What is the difference between stocks, equity and shares?</em></p><p>The terms stock and equity are often used interchangeably. Stock is a general term that refers to an unspecified amount of ownership interest in a company. Shares represent the way that a company’s stock is divided. A company’s stock can be divided into a potentially limitless number of shares, each worth exactly the same value. Equity you have already learned above.</p><p>3. <em>What is the difference between startup founders and entrepreneurs?</em></p><p>The difference<strong> </strong>between<strong> </strong>entrepreneurs and startup founders is that entrepreneurs have major responsibilities and are very focused on earning money. Entrepreneurs are called the people who take part in trades, sell things, make money to survive, run companies and simply are trying to keep their businesses profitable. On the other hand, Startup founders tend to be visionary and more accepting of failures to fine-tune their product. They have issues with bigger and broader teams post the Startup or even during that phase. It can be a rigid and single-pointed focus and may lose the bigger picture.</p><p>Thanks, please ask any questions in comments.</p><p>If you want more motivations to open a startup then watch this video of Oyo’s founder -<a href="https://www.linkedin.com/in/riteshagar?originalSubdomain=in">Ritesh Agrawal</a><br><a href="https://www.youtube.com/watch?v=snychWgbJxU">https://www.youtube.com/watch?v=snychWgbJxU</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d56a0cbd26b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google App Actions -Basics and Implementation]]></title>
            <link>https://medium.com/@vikas.bajpayee/google-app-actions-basics-and-implementation-1e462d30007?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e462d30007</guid>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Sat, 07 Sep 2019 11:33:52 GMT</pubDate>
            <atom:updated>2019-09-09T04:16:15.473Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What are App Actions?</strong></p><p>App Actions let users launch specific features in your app using the Google Assistant. By enabling App Actions to extend your app, users can easily deep link into your apps via the Assistant by simply speaking a request to the Assistant. If the user has your app already installed, the Assistant triggers deep linking when users say an invocation phrase that includes your app name, such as ”Ok Google, order a vanilla marshmallow smore from smores app”.</p><h3>How does it work?</h3><p>From a user’s perspective, App Actions behave like shortcuts to parts of your Android app.</p><p>When users invoke an App Action, the Assistant either launches a screen in the Android app that the user has already installed or shows an embedded visual card (Android Slice) that users can interact with.</p><p>For example, the user could say</p><p><strong>“Hey Google, order a ride to Pasaraya Blok m with gojek”</strong> to launch the gojek app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*mqNEjTvtnQ0kaFYvHhuZ5w.gif" /><figcaption>image taken from gojek app</figcaption></figure><p>Internally, when a user’s query matches the built-in intent grammar, the Assistant extracts the query parameters into schema.org entities and generates an Android deep link URL using the mappings you provide through the actions.xml file. Actions on Google then uses the deep link URL, prefilled with user-supplied parameters, to take users directly to specific content in your Android app without additional conversational dialog.</p><h3>Steps to implement this feature:-</h3><ol><li><strong>Choose App Actions target</strong>:- Ensure the Activity can be started by the system via an intent. We can do this either by deep links or slices.</li><li><strong>Create the actions.xml file:</strong>- Define all your Intents here which u want to support in your app.</li><li><strong>Preview your App Actions:-</strong> You can use the App Actions test tool to test that App Actions work for your app.</li><li><strong>Deploy to play console:-</strong> fill the form for actions defined in your actions.xml in play-console.</li></ol><p>let’s get into the details.</p><ol><li><strong>Choose App Actions target</strong></li></ol><p>When you type something on assistant then assistant search for a method or target to go to your app now for these targets you can use only:- deeplinks or slices. we only have these two options as a target to implements this feature.</p><p><em>a) Using Deeplinks</em></p><p>App Actions start Android activities via deep links that the Assistant generates. The deep link can be based on <a href="https://developer.android.com/training/app-links/index.html">App Links URLs</a>, <a href="https://developer.chrome.com/multidevice/android/intents">Intent-based URLs</a>, or custom schemes (for example: “example://test/foo=bar”). First of all, Define host and schema in manifest in the activity where you are defining your deep links.</p><pre><br>&lt;data<br> android:scheme=”test”<br> android:host=&quot;example&quot;/&gt;</pre><p>example if we want to choose your target as a deeplink then u can access your activity(or screen) using this deeplink.</p><p>To test that your Activities are accessible and that they can be triggered using App Actions, run this adb command:</p><pre>$ adb shell am start -a android.intent.action.VIEW -d &quot;[App Links URL]&quot;</pre><p>For example:</p><pre>$ adb shell am start -a android.intent.action.VIEW -d &quot;example://test&quot;</pre><p><em>b) Using Slices</em></p><p>Google recommends implementing slices always because then your app is a quick inline answer or a simple confirmation that an action was taken. It means your assistant will be more responsive if you do this.</p><h4>Now, What are Android slices?</h4><p>UI templates that can be displayed by another app.part of the android jetpack. basically, they display all the work which is done by your app actions at the end. slices are part of app actions. it builds interactive results for google search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*TKqcHuKGgztp18NSJsdXoA.png" /><figcaption>Launching a Slice using GET_INVOICE</figcaption></figure><p><strong>2. Create actions.xml file</strong></p><p>Create a res/xml/actions.xml file and then link it in &lt;meta-data&gt; tag in Android’s manifest.xml.</p><pre><em>&lt;meta-data android:name=”com.google.android.actions”<br> android:resource=”@xml/actions”/&gt;</em></pre><p>Now, do this for deeeplinks implementation in your actions.xml file(example if you want to integrate ride app actions)</p><pre>&lt;<strong>action intentName=&quot;actions.intent.CREATE_TAXI_RESERVATION&quot;</strong>&gt;<br>    <em><br>    </em>&lt;<strong>fulfillment<br>        fulfillmentMode=&quot;actions.fulfillment.DEEPLINK&quot;<br>        urlTemplate=&quot;example://test/ga&quot;</strong>&gt;<br>   <strong> &lt;/fullfillment&gt;<br>&lt;/action&gt;</strong></pre><p>For slices implementation do this in your actions.xml file</p><pre>&lt;<strong>action intentName=&quot;actions.intent.CREATE_TAXI_RESERVATION&quot;</strong>&gt;<br>    <em><br>    </em>&lt;<strong>fulfillment<br>        fulfillmentMode=&quot;actions.fulfillment.SLICE&quot;<br>        urlTemplate=&quot;example://test/ga&quot;</strong>&gt;<br>   <strong> &lt;/fullfillment&gt;<br>&lt;/action&gt;</strong></pre><p><strong>3. Preview your app actions</strong></p><blockquote>Testing app actions is difficult, so writing some steps here to follow:-</blockquote><p>There is a special plugin for testing app actions — <a href="https://developers.google.com/actions/appactions/quickstart#preview"><strong>App Actions test </strong></a><strong>tool,</strong> It is a special app actions plugin for testing app actions. It parses and creates preview actions from actions.xml. It uses google account to test in Assistant.</p><p>To test this in your device, you must follow these steps:-<br>a) The google account using which you are loggedin in Android Studio must be same as the one in the testing device.</p><p>b) The google account you are using for testing must own or have access in Play console to the applicationId defined in build.gradle. It means there is no need of that you must have google play account, u can get a testing account from another developer(who has an account on play console) and can test your application.</p><p>c) Android Studio has access to an internet connection.</p><p>d) If you modified the actions.xml, make sure the right syntax is used.</p><p><strong>4. Deploy it on Play Console</strong></p><p>Now it’s a time for publishing your app on play console with this feature. But wait, for doing this you have to take some steps, it’s not just like normal way of uploading apk to google. Here are some steps which you have to follow while uploading your apk:-</p><ol><li><strong><em>Complete the form on our developer site. upload the app binary to google play.</em></strong></li></ol><p>If we want to Deploy App Actions we have to fill this form first and send a request to google:- <a href="https://developers.google.com/actions/appactions/deployment-request">https://developers.google.com/actions/appactions/deployment-request</a></p><p><strong><em>2. Fulfil additional app actions requirements:-</em></strong></p><p>To ensure that users enjoy a seamless experience when using App Actions, you must meet these requirements before activating App Actions for your app:</p><p><strong>a) Log contextual content:- </strong>By implementing <a href="https://developer.android.com/reference/android/app/Activity#onProvideAssistContent(android.app.assist.AssistContent)">onProvideAssistContent()</a>, we provide the Assistant with structured information about the current foreground content. This contextual information enables the Assistant to continue being helpful after the user enters your app.</p><p><strong>b) Report interaction results:- </strong>Google monitors the health of your App Actions to know when they aren’t working as intended. You must let Google know using Firebase whether your app successfully handled a built-in intent with App Actions.<br><a href="https://firebase.google.com/docs/app-indexing/android/app#add-firebase-and-the-app-indexing-library">Reference</a></p><p><em>i). Add Firebase App-indexing library.</em></p><p><em>ii) Structure links to your app content</em> — Structure your website and app so the URLs that point to pages on your site are the same URLs that point to views in your Android app. Google Search crawls your site for these links, then uses them to send users directly to your app.</p><p><em>iii) Add app links to your app</em></p><p>Now if we want result like this:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*0Hs7BeeVAKtAmV3z" /></figure><p>Means google search will show your app as a suggestion while searching on google.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e462d30007" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Memory leaks and Garbage collection]]></title>
            <link>https://medium.com/@vikas.bajpayee/android-memory-leaks-and-garbage-collection-c8f95af0d247?source=rss-c3f7354c81b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8f95af0d247</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[memory-leak]]></category>
            <category><![CDATA[garbage-collection]]></category>
            <dc:creator><![CDATA[Vikas Bajpayee]]></dc:creator>
            <pubDate>Thu, 29 Aug 2019 16:22:52 GMT</pubDate>
            <atom:updated>2021-08-23T10:11:08.736Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CypaZehcZksTWzgVgskiqA.jpeg" /></figure><blockquote><strong>Making an android app is easy, but making high performance, high-quality, and memory-efficient android app is not that easy as you think.</strong></blockquote><p>I have been an android developer for quite some time now. And I realised that most of that time, I spend time on working new projects without thinking about their performance, quality etc, adding new features to an app or working on visual enhancements of the app, rather than focusing on the core issues like app performance and quality.</p><p>But nowadays I am spending my lots of time on these things and while creating apps I am not ignoring these things seriously. So in this article, I will mostly talk about optimization technique:- <strong>Memory Leak.</strong></p><p><strong>Memory Leak:- </strong>A memory leak happens when memory is allocated but never freed. This means the garbage collector is not able to take out the trash once we are done with the takeout. Many a time we see ANR(Application not responding) dialog while using android apps, lags in our apps, we also see OutOfMemoryError in Android Studio while building apps. All these kinds of stuff happen due to memory leaks. Some objects are not even recognized by the garbage collector as garbage.</p><p><strong>Effects of Memory leak</strong></p><p>1. Lags in our app</p><p>2. Application Not Responding(ANR) dialog</p><p>3. OutOfMemory error while building your app.</p><p>So should you really care about this term while designing your apps:- <strong>Memory Leak</strong>?</p><p>So, If you want that your app will not eat up lots of memory and don’t crash after using for some time then take this term seriously. 😐</p><p><strong>How we can detect Memory Leaks?</strong></p><p>1. We can use a tool called LeakCanary. It is a good tool for detecting memory leaks in your app. It creates weak references to activities in your app. (You can also customize it by adding watches to any other objects.) It then checks if the reference is cleared after GC. If not, it dumps heap into a .hprof file and analyze it to confirm if there is a leak. If there is one, it shows a notification and in a separate app, it shows the reference tree of how the leak happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/0*9bRgCcSOQrmkCPOp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/0*73iErewtkWrRUDTq" /></figure><p>2. We can also detect it using our well-known best friendly tool — Android Studio also, yes we can also detect Memory leaks using Android studio also.</p><p>Have a look at this how:-</p><p>a) First, build your program and run it on your device.<br> b) Open that activity which you want to test whether it’s leaking your activity or not.<br> c) In Android Studio -&gt; Android Monitor window -&gt; Memory section, click on Initiate GC button. Then click on Dump Java Heap button.<br> d) Android Studio will open the dumped .hprof file. In the <strong>hprof</strong> file viewer, there are a couple of ways you can check the memory leak. You can use the Analyzer Tasks tool on the top right corner to detect leaked activities automatically. Or you can switch the view mode to Package Tree View from the top left corner, find the activity which should be destroyed. Check the Total Count of the activity object. If there are 1 or more instances, it means there is a leak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/0*3N_WLkNsZqGWdI5A" /></figure><p>Fig:- It shows your memory usages</p><p><strong>Garbage Collection:-</strong></p><p>Memory utilization on the mobile app has a significant impact on customer experience. If your app creates a lot of objects, then the Android run time (ART) environment will trigger garbage collection (GC) frequently. Android garbage collection is an automatic process which removes unused objects from memory. However, frequent garbage collection consumes a lot of CPU, and it will also pause the app. Frequent pauses can jank the app (i.e. stuttering, juddering, or halting).</p><p>Thus, you need to understand how many objects your app is creating, how frequently garbage collection is triggered, how much time it takes to complete, and how much memory is reclaimed after every event. All this information is present in the runtime log messages. Whenever a GC event runs, a logline is printed in the runtime log messages. You can view those log lines through <a href="https://developer.android.com/studio/debug/am-logcat.html">logcat</a>.</p><p>It will look like this:-</p><p>07–01 16:00:44.690: I/art(801): Explicit concurrent mark sweep GC freed 65595(3MB) AllocSpace objects, 9(4MB) LOS objects, 34% free, 38MB/58MB, paused 1.195ms total 87.219ms</p><p><strong>How Garbage Collector and Memory leaks are related to each other?</strong></p><p>Java automatically garbage collect objects to release memory. Garbage collection means that an object which is not reachable via any live reference can be removed from memory. In this way, the user is not concerned about memory allocation and deallocation. However, sometimes this automatic process fails to free enough memory which results in memory leaks. Memory leaks make your application slow and you can also get out of memory exceptions.</p><p><strong>There can be many reasons for memory leak:-</strong></p><p>Let’s talk about these in details:-<br><strong>1. Using Inner classes — </strong>If you are using an inner class, use this as static because the static class does not need the outer class implicit reference. Using inner class as non-static makes the outer class alive so it is better to avoid.</p><p><strong>2. Using anonymous classes</strong></p><p><strong>3. Using context — </strong>Use the right context at the right place, like use applicationContext only where it’s required, similarly use activityContext only where it’s required.</p><p><strong>4. Using static views or context — </strong>Never use static views or context in your context because static keyword thing is always visible and it can’t be killed.</p><p><strong>5. Unregister broadcast receiver if you are not using it — </strong>Consider this scenario — you need to register a local broadcast receiver in your activity. If you don’t unregister the broadcast receiver, then it still holds a reference to the activity, even if you close the activity.</p><p><strong>6. When you pass your activity as a listener to a singleton object or an x-manager instance, make sure you understand what the other object does with the activity instance you passed in. Clear the reference (set the listener to null) if necessary on Activity onDestroy.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8f95af0d247" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>