<?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 Gurwinder Singh on Medium]]></title>
        <description><![CDATA[Stories by Gurwinder Singh on Medium]]></description>
        <link>https://medium.com/@gurwindersingh_37022?source=rss-ec45a16dae9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wcIV_il4OLARZwcFUJen4A.jpeg</url>
            <title>Stories by Gurwinder Singh on Medium</title>
            <link>https://medium.com/@gurwindersingh_37022?source=rss-ec45a16dae9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:38:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gurwindersingh_37022/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[Jetpack Compose and MVI Architecture]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Modern mobile development is shifting toward declarative UI frameworks that simplify creating dynamic interfaces. In the Android world&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@gurwindersingh_37022/jetpack-compose-and-mvi-architecture-c8697159f3a7?source=rss-ec45a16dae9d------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@gurwindersingh_37022/jetpack-compose-and-mvi-architecture-c8697159f3a7?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8697159f3a7</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 08:50:17 GMT</pubDate>
            <atom:updated>2025-10-07T09:05:06.871Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[GraphQL- Android Integration]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">GraphQL is a powerful query language for APIs, enabling clients to request exactly the data they need. Integrating GraphQL into Android&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@gurwindersingh_37022/graphql-android-integration-c8ed5c3a263b?source=rss-ec45a16dae9d------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@gurwindersingh_37022/graphql-android-integration-c8ed5c3a263b?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8ed5c3a263b</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[query-language]]></category>
            <category><![CDATA[graph]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 22:11:11 GMT</pubDate>
            <atom:updated>2025-09-14T22:11:52.280Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Deep Linking in Android/iOS Part-2]]></title>
            <link>https://medium.com/@gurwindersingh_37022/deep-linking-in-android-ios-part-2-20d75a32f78?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/20d75a32f78</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 06:40:17 GMT</pubDate>
            <atom:updated>2020-09-14T06:40:17.321Z</atom:updated>
            <content:encoded><![CDATA[<p>Deep linking is the most common feature almost implemented in all applications. The dashboard setup is explained in the <a href="https://medium.com/@gurwindersingh_37022/deep-linking-in-android-ios-part-1-87800b0321d">Part-1</a> blog. If you not read, please <a href="https://medium.com/@gurwindersingh_37022/deep-linking-in-android-ios-part-1-87800b0321d">read</a> it for complete understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*DzLZpcr6nsqPjaOV.png" /></figure><h3><strong>Implementation in Android:</strong></h3><h3><strong>Dependencies:</strong></h3><blockquote>implementation ‘io.branch.sdk.android:library:5.+</blockquote><p>‘+’ refer for the latest updated and stable(Geniune) version. Please make sure, if you are using Android X dependencies, the project must be in Android X otherwise use legacy support dependencies.</p><h4><strong>Android Manifest</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253C%21%2525E2%252580%25258A-%2525E2%252580%25258ABranch%252520URI%252520Scheme%252520%2525E2%252586%252592%2525C2%2525A0%25250A%25253Cintent-filter%25253E%2525C2%2525A0%252520%25250A%25253Cdata%252520android%25253Ascheme%25253D%252522%25253CAdd%252520URI%252520Scheme%252520from%252520Branch.io%252520dashboard%252520refer%252520part%2525201%25253E%252522%252520%25252F%25253E%2525C2%2525A0%25250A%252520%252520%25253C%21%2525E2%252580%25258A-%2525E2%252580%25258AAction%252520for%252520open%252520the%252520application%252520%252520%2525E2%252586%252592%2525C2%2525A0%25250A%252520%252520%252520%25253Caction%252520android%25253Aname%25253D%252522android.intent.action.VIEW%252522%252520%25252F%25253E%25250A%2525C2%2525A0%252520%252520%25253Ccategory%252520android%25253Aname%25253D%252522android.intent.category.DEFAULT%252522%252520%25252F%25253E%25250A%252520%252520%252520%25253Ccategory%252520android%25253Aname%25253D%252522android.intent.category.BROWSABLE%252522%252520%25252F%25253E%252520%25250A%25253C%25252Fintent-filter%25253E%2525C2%2525A0%25250A%25250A%25253C%21%2525E2%252580%25258A-%2525E2%252580%25258ABranch%252520App%252520Links%252520%28optional%29%252520%2525E2%252586%252592%2525C2%2525A0%25250A%25253Cintent-filter%252520android%25253AautoVerify%25253D%252522true%252522%252520%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520android%25253Ahost%25253D%252522open%252522%25250A%25253E%2525C2%2525A0%25252F%25252F%252520autoVerify%252520is%252520used%252520to%252520local%25252Ftest%252520mode%252520deeplinking%252520enable%252520and%252520host%252520for%252520open%252520app%252520on%252520click%252520on%252520link.%25250A%252520%252520%25250A%252520%252520%25253Caction%252520android%25253Aname%25253D%252522android.intent.action.VIEW%252522%252520%25252F%25253E%2525C2%2525A0%25250A%252520%252520%25253Ccategory%252520android%25253Aname%25253D%252522android.intent.category.DEFAULT%252522%252520%25252F%25253E%2525C2%2525A0%25250A%252520%252520%25253Ccategory%252520android%25253Aname%25253D%252522android.intent.category.BROWSABLE%252522%252520%25252F%25253E%2525C2%2525A0%25250A%252520%252520%25253Cdata%252520android%25253Ascheme%25253D%252522https%252522%252520android%25253Ahost%25253D%252522%25253CAdd%252520branch.io%252520host%252520name%252520from%252520dashboard%252520refer%252520part-1%252520%25253E%252522%25252F%25253E%2525C2%2525A0%25250A%25253C%21%2525E2%252580%25258A-%2525E2%252580%25258Aexample-alternate%252520domain%252520is%252520required%252520for%252520App%252520Links%252520when%252520the%252520Journeys%25252FWeb%252520SDK%252520and%252520Deepviews%252520are%252520used%252520inside%252520your%252520website.%252520%2525E2%252586%252592%2525C2%2525A0%25250A%25253Cdata%252520android%25253Ascheme%25253D%252522https%252522%252520android%25253Ahost%25253D%252522example-alternate.app.link%252522%252520%25252F%25253E%2525C2%2525A0%25250A%25253C%25252Fintent-filter%25253E&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253C%21%252525E2%25252580%2525258A-%252525E2%25252580%2525258ABranch%25252520URI%25252520Scheme%25252520%252525E2%25252586%25252592%252525C2%252525A0%2525250A%2525253Cintent-filter%2525253E%252525C2%252525A0%25252520%2525250A%2525253Cdata%25252520android%2525253Ascheme%2525253D%25252522%2525253CAdd%25252520URI%25252520Scheme%25252520from%25252520Branch.io%25252520dashboard%25252520refer%25252520part%252525201%2525253E%25252522%25252520%2525252F%2525253E%252525C2%252525A0%2525250A%25252520%25252520%2525253C%21%252525E2%25252580%2525258A-%252525E2%25252580%2525258AAction%25252520for%25252520open%25252520the%25252520application%25252520%25252520%252525E2%25252586%25252592%252525C2%252525A0%2525250A%25252520%25252520%25252520%2525253Caction%25252520android%2525253Aname%2525253D%25252522android.intent.action.VIEW%25252522%25252520%2525252F%2525253E%2525250A%252525C2%252525A0%25252520%25252520%2525253Ccategory%25252520android%2525253Aname%2525253D%25252522android.intent.category.DEFAULT%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%2525253Ccategory%25252520android%2525253Aname%2525253D%25252522android.intent.category.BROWSABLE%25252522%25252520%2525252F%2525253E%25252520%2525250A%2525253C%2525252Fintent-filter%2525253E%252525C2%252525A0%2525250A%2525250A%2525253C%21%252525E2%25252580%2525258A-%252525E2%25252580%2525258ABranch%25252520App%25252520Links%25252520%28optional%29%25252520%252525E2%25252586%25252592%252525C2%252525A0%2525250A%2525253Cintent-filter%25252520android%2525253AautoVerify%2525253D%25252522true%25252522%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520android%2525253Ahost%2525253D%25252522open%25252522%2525250A%2525253E%252525C2%252525A0%2525252F%2525252F%25252520autoVerify%25252520is%25252520used%25252520to%25252520local%2525252Ftest%25252520mode%25252520deeplinking%25252520enable%25252520and%25252520host%25252520for%25252520open%25252520app%25252520on%25252520click%25252520on%25252520link.%2525250A%25252520%25252520%2525250A%25252520%25252520%2525253Caction%25252520android%2525253Aname%2525253D%25252522android.intent.action.VIEW%25252522%25252520%2525252F%2525253E%252525C2%252525A0%2525250A%25252520%25252520%2525253Ccategory%25252520android%2525253Aname%2525253D%25252522android.intent.category.DEFAULT%25252522%25252520%2525252F%2525253E%252525C2%252525A0%2525250A%25252520%25252520%2525253Ccategory%25252520android%2525253Aname%2525253D%25252522android.intent.category.BROWSABLE%25252522%25252520%2525252F%2525253E%252525C2%252525A0%2525250A%25252520%25252520%2525253Cdata%25252520android%2525253Ascheme%2525253D%25252522https%25252522%25252520android%2525253Ahost%2525253D%25252522%2525253CAdd%25252520branch.io%25252520host%25252520name%25252520from%25252520dashboard%25252520refer%25252520part-1%25252520%2525253E%25252522%2525252F%2525253E%252525C2%252525A0%2525250A%2525253C%21%252525E2%25252580%2525258A-%252525E2%25252580%2525258Aexample-alternate%25252520domain%25252520is%25252520required%25252520for%25252520App%25252520Links%25252520when%25252520the%25252520Journeys%2525252FWeb%25252520SDK%25252520and%25252520Deepviews%25252520are%25252520used%25252520inside%25252520your%25252520website.%25252520%252525E2%25252586%25252592%252525C2%252525A0%2525250A%2525253Cdata%25252520android%2525253Ascheme%2525253D%25252522https%25252522%25252520android%2525253Ahost%2525253D%25252522example-alternate.app.link%25252522%25252520%2525252F%2525253E%252525C2%252525A0%2525250A%2525253C%2525252Fintent-filter%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/794406928dd8354966853733d9b601d7/href">https://medium.com/media/794406928dd8354966853733d9b601d7/href</a></iframe><h4><strong>Add Branch.iO Keys</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520%252520%252520%252520%252520%25253C%21--%252520Branch%252520init%252520--%25253E%25250A%252520%252520%252520%252520%252520%252520%25253Cmeta-data%252520android%25253Aname%25253D%252522io.branch.sdk.BranchKey%252522%25250A%252520%252520%252520%252520%252520%252520android%25253Avalue%25253D%252522%25253CAdd%252520Branch%252520key%252520from%252520dashboard%25253E%252522%252520%25252F%25253E%25250A%25250A%252520%252520%252520%252520%252520%252520%25253Cmeta-data%252520android%25253Aname%25253D%252522io.branch.sdk.BranchKey.test%252522%252520%252509%252520%252520%252520%252520%252520%252520%252520%252520%252520%25250A%252520%252520%252520%252520%252520%252520android%25253Avalue%25253D%252522%25253C%252520Add%252520Test%252520Key%252520from%252520branch.io%252520DashBoard%252520%25253E%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25250A%252520%252520%252520%252520%252520%252520%25253Cmeta-data%252520android%25253Aname%25253D%252522io.branch.sdk.TestMode%252522%252520android%25253Avalue%25253D%252522false%252522%252520%25252F%25253E%252520%252520%25250A%252520%252520%252520%252520%252520%252520%25253C%21--%252520Set%252520to%252520true%252520to%252520use%252520Branch_Test_Key%252520%28useful%252520when%252520simulating%252520installs%252520%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520and%25252For%252520switching%252520between%252520debug%252520and%252520production%252520flavors%29%252520--%25253E%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%21--%25252520Branch%25252520init%25252520--%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Cmeta-data%25252520android%2525253Aname%2525253D%25252522io.branch.sdk.BranchKey%25252522%2525250A%25252520%25252520%25252520%25252520%25252520%25252520android%2525253Avalue%2525253D%25252522%2525253CAdd%25252520Branch%25252520key%25252520from%25252520dashboard%2525253E%25252522%25252520%2525252F%2525253E%2525250A%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Cmeta-data%25252520android%2525253Aname%2525253D%25252522io.branch.sdk.BranchKey.test%25252522%25252520%25252509%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520android%2525253Avalue%2525253D%25252522%2525253C%25252520Add%25252520Test%25252520Key%25252520from%25252520branch.io%25252520DashBoard%25252520%2525253E%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Cmeta-data%25252520android%2525253Aname%2525253D%25252522io.branch.sdk.TestMode%25252522%25252520android%2525253Avalue%2525253D%25252522false%25252522%25252520%2525252F%2525253E%25252520%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%21--%25252520Set%25252520to%25252520true%25252520to%25252520use%25252520Branch_Test_Key%25252520%28useful%25252520when%25252520simulating%25252520installs%25252520%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520and%2525252For%25252520switching%25252520between%25252520debug%25252520and%25252520production%25252520flavors%29%25252520--%2525253E%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fe616d27d100b238894238e0559c3a1/href">https://medium.com/media/4fe616d27d100b238894238e0559c3a1/href</a></iframe><h4><strong>Initialize in Application Class</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dpublic%252520class%252520CustomApplicationClass%252520extends%252520Application%252520%25257B%25250A%252520%252520%252520%252520%252540Override%25250A%252520%252520%252520%252520public%252520void%252520onCreate%28%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520super.onCreate%28%29%25253B%25250A%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25252F%25252F%252520Branch%252520logging%252520for%252520debugging%25250A%252520%252520%252520%252520%252520%252520%252520%252520Branch.enableLogging%28%29%25253B%25250A%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25252F%25252F%252520Branch%252520object%252520initialization%25250A%252520%252520%252520%252520%252520%252520%252520%252520Branch.getAutoInstance%28this%29%25253B%25250A%252520%252520%252520%252520%25257D%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dpublic%25252520class%25252520CustomApplicationClass%25252520extends%25252520Application%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252540Override%2525250A%25252520%25252520%25252520%25252520public%25252520void%25252520onCreate%28%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520super.onCreate%28%29%2525253B%2525250A%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520Branch%25252520logging%25252520for%25252520debugging%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Branch.enableLogging%28%29%2525253B%2525250A%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520Branch%25252520object%25252520initialization%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Branch.getAutoInstance%28this%29%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b730e0f9a7b98549d34129a3c30e5b3/href">https://medium.com/media/7b730e0f9a7b98549d34129a3c30e5b3/href</a></iframe><h4>Parse Data from Intent in Launcher activity</h4><blockquote>public class LauncherActivity extends AppCompatActivity {</blockquote><blockquote><a href="http://twitter.com/Override">@Override</a><br> protected void onCreate(Bundle savedInstanceState) {<br> super.onCreate(savedInstanceState);<br> setContentView(R.layout.activity_launcher);<br> }</blockquote><blockquote><a href="http://twitter.com/Override">@Override</a> public void onStart() {<br> super.onStart();<br> <strong>Branch.sessionBuilder(this)<br> .withCallback(branchReferralInitListener)<br> .withData(getIntent() != null ? getIntent().getData() : null).init();</strong><br> }<br> <a href="http://twitter.com/Override">@Override</a><br> protected void onNewIntent(Intent intent) {<br> super.onNewIntent(intent);<br> setIntent(intent);<br><strong> /* if activity is in foreground (or in backstack but partially visible) launching the same activity will skip onStart, handle this case with reInitSession*/<br> Branch.sessionBuilder(this)<br> .withCallback(branchReferralInitListener)<br> .reInit();</strong><br> }<br> private Branch.BranchReferralInitListener branchReferralInitListener=<br> new Branch.BranchReferralInitListener() {<br> <a href="http://twitter.com/Override">@Override</a><br> public void onInitFinished(JSONObject linkProperties,<br> BranchError error<br> ) {<br> // do stuff with deep link data (nav to page, display content, etc)<br> }<br> };</blockquote><h4>Add Proguard rules</h4><blockquote>-keep class com.google.android.gms.** { *; }</blockquote><blockquote>keep class com.huawei.hms.ads.** { *; }</blockquote><blockquote>-keep interface com.huawei.hms.ads.** { *; }</blockquote><p><strong>Generate URL using branch.io</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DBranchUniversalObject%252520buo%252520%25253D%252520new%252520BranchUniversalObject%28%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setCanonicalIdentifier%28%252522content%25252F12345%252522%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setTitle%28%252522My%252520Content%252520Title%252522%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setContentDescription%28%252522My%252520Content%252520Description%252522%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setContentImageUrl%28%252522https%25253A%25252F%25252Florempixel.com%25252F400%25252F400%252522%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setContentIndexingMode%28BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setLocalIndexMode%28BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520.setContentMetadata%28new%252520ContentMetadata%28%29.addCustomMetadata%28%252522key1%252522%25252C%252520%252522value1%252522%29%29%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520.generateShortUrl%28this%25252C%252520linkProperties%25252C%252520new%252520BranchLinkCreateListener%28%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252540Override%25250A%252520%252520%252520%252520%252520%252520%252520%252520public%252520void%252520onLinkCreate%28String%252520url%25252C%252520BranchError%252520error%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520if%252520%28error%252520%25253D%25253D%252520null%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520Log.i%28%252522MyApp%252522%25252C%252520%252522got%252520my%252520Branch%252520link%252520to%252520share%25253A%252520%252522%252520%25252B%252520url%29%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%25257D%29%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DBranchUniversalObject%25252520buo%25252520%2525253D%25252520new%25252520BranchUniversalObject%28%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setCanonicalIdentifier%28%25252522content%2525252F12345%25252522%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setTitle%28%25252522My%25252520Content%25252520Title%25252522%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setContentDescription%28%25252522My%25252520Content%25252520Description%25252522%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setContentImageUrl%28%25252522https%2525253A%2525252F%2525252Florempixel.com%2525252F400%2525252F400%25252522%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setContentIndexingMode%28BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setLocalIndexMode%28BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.setContentMetadata%28new%25252520ContentMetadata%28%29.addCustomMetadata%28%25252522key1%25252522%2525252C%25252520%25252522value1%25252522%29%29%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.generateShortUrl%28this%2525252C%25252520linkProperties%2525252C%25252520new%25252520BranchLinkCreateListener%28%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252540Override%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520public%25252520void%25252520onLinkCreate%28String%25252520url%2525252C%25252520BranchError%25252520error%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520if%25252520%28error%25252520%2525253D%2525253D%25252520null%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Log.i%28%25252522MyApp%25252522%2525252C%25252520%25252522got%25252520my%25252520Branch%25252520link%25252520to%25252520share%2525253A%25252520%25252522%25252520%2525252B%25252520url%29%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%2525257D%29%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8c75c77e0e2e297bc83955896cb324b/href">https://medium.com/media/e8c75c77e0e2e297bc83955896cb324b/href</a></iframe><h4>Read Data from URL</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252F%252520listener%252520%28within%252520Main%252520Activity%2527s%252520onStart%29%25250A%252520%252520%252520%252520Branch.sessionBuilder%28this%29.withCallback%28new%252520Branch.BranchReferralInitListener%28%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252540Override%25250A%252520%252520%252520%252520%252520%252520%252520%252520public%252520void%252520onInitFinished%28JSONObject%252520referringParams%25252C%252520BranchError%252520error%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520if%252520%28error%252520%25253D%25253D%252520null%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520Log.i%28%252522%252522BRANCH%252520SDK%252522%252522%25252C%252520referringParams.toString%28%29%29%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%252520else%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520Log.i%28%252522%252522BRANCH%252520SDK%252522%252522%25252C%252520error.getMessage%28%29%29%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%25257D%29.withData%28this.getIntent%28%29.getData%28%29%29.init%28%29%25253B%25250A%25250A%252520%252520%252520%252520%25252F%25252F%252520latest%25250A%252520%252520%252520%252520JSONObject%252520sessionParams%252520%25253D%252520Branch.getInstance%28%29.getLatestReferringParams%28%29%25253B%25250A%25250A%252520%252520%252520%252520%25252F%25252F%252520first%25250A%252520%252520%252520%252520JSONObject%252520installParams%252520%25253D%252520Branch.getInstance%28%29.getFirstReferringParams%28%29%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252F%25252520listener%25252520%28within%25252520Main%25252520Activity%252527s%25252520onStart%29%2525250A%25252520%25252520%25252520%25252520Branch.sessionBuilder%28this%29.withCallback%28new%25252520Branch.BranchReferralInitListener%28%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252540Override%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520public%25252520void%25252520onInitFinished%28JSONObject%25252520referringParams%2525252C%25252520BranchError%25252520error%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520if%25252520%28error%25252520%2525253D%2525253D%25252520null%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Log.i%28%25252522%25252522BRANCH%25252520SDK%25252522%25252522%2525252C%25252520referringParams.toString%28%29%29%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%25252520else%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Log.i%28%25252522%25252522BRANCH%25252520SDK%25252522%25252522%2525252C%25252520error.getMessage%28%29%29%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%2525257D%29.withData%28this.getIntent%28%29.getData%28%29%29.init%28%29%2525253B%2525250A%2525250A%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520latest%2525250A%25252520%25252520%25252520%25252520JSONObject%25252520sessionParams%25252520%2525253D%25252520Branch.getInstance%28%29.getLatestReferringParams%28%29%2525253B%2525250A%2525250A%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520first%2525250A%25252520%25252520%25252520%25252520JSONObject%25252520installParams%25252520%2525253D%25252520Branch.getInstance%28%29.getFirstReferringParams%28%29%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/725899b1a9dc965c70a1fd356151426c/href">https://medium.com/media/725899b1a9dc965c70a1fd356151426c/href</a></iframe><h4>Branch Logout</h4><blockquote>Branch.getInstance().logout();</blockquote><h3><strong>iOS implementation</strong></h3><h4><strong>Add Branch.iO Framework:</strong></h4><p><a href="https://github.com/BranchMetrics/ios-branch-deep-linking-attribution">BranchMetrics/ios-branch-deep-linking-attribution</a></p><ul><li>Set Bundle Identifier same as registred in Branch.iO Dashboard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cC5iHKCp71AXeYXo.png" /></figure><p>. Add Domain for deep linking from Branch.iO Dashboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MEeLQH9AV8TW280r.png" /></figure><p>Add Branch.iO Keys</p><h3>Configure Info.plist</h3><p>Add branch_universal_link_domains with your live key domain</p><p>Add branch_key with your current Branch key</p><p>Add your URI scheme as URL Types -&gt; Item 0 -&gt; URL Schemes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fxm4n_6unApDwD88.png" /></figure><h3><strong>Application Delegate</strong></h3><blockquote>func application(_ application: UIApplication,<br> didFinishLaunchingWithOptions launchOptions:<br> [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool<br>{<br> // if you are using the TEST key<br> Branch.setUseTestBranchKey(true)<br> // listener for Branch Deep Link data<br> Branch.getInstance()<br> .initSession(launchOptions: launchOptions){ (params, error) in<br> // do stuff with deep link data (nav to page, display content, etc)<br> print(params as? [String: AnyObject] ?? {})<br> }<br> return true<br>}</blockquote><blockquote>func application(_ app: UIApplication,<br> open url: URL,<br> options: [UIApplication.OpenURLOptionsKey : Any] = [:]<br> ) -&gt; Bool {<br> return Branch<br> .getInstance()<br> .application(app, open: url, options: options)<br>}</blockquote><blockquote>func application(_ application: UIApplication,<br> continue userActivity: NSUserActivity,<br> restorationHandler: <a href="http://twitter.com/escaping">@escaping</a> ([UIUserActivityRestoring]?) -&gt; Void<br> ) -&gt; Bool {<br> // handler for Universal Links<br> return Branch.getInstance().continue(userActivity)<br>}</blockquote><blockquote>func application(_ application: UIApplication,<br> didReceiveRemoteNotification userInfo:[AnyHashable : Any],<br> fetchCompletionHandler completionHandler: <br> <a href="http://twitter.com/escaping">@escaping</a> (UIBackgroundFetchResult) -&gt; Void<br> ) {<br> // handler for Push Notifications<br> Branch.getInstance().handlePushNotification(userInfo)<br>}</blockquote><p><strong>Open Scene based on Link</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520func%252520scene%28_%252520scene%25253A%252520UIScene%25252C%252520openURLContexts%252520URLContexts%25253A%252520Set%25253CUIOpenURLContext%25253E%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520BranchScene.shared%28%29.scene%28scene%25252C%252520openURLContexts%25253A%252520URLContexts%29%25250A%252520%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520func%25252520scene%28_%25252520scene%2525253A%25252520UIScene%2525252C%25252520openURLContexts%25252520URLContexts%2525253A%25252520Set%2525253CUIOpenURLContext%2525253E%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520BranchScene.shared%28%29.scene%28scene%2525252C%25252520openURLContexts%2525253A%25252520URLContexts%29%2525250A%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfd8862b572137f23b98954a8819e06e/href">https://medium.com/media/dfd8862b572137f23b98954a8819e06e/href</a></iframe><h4>Logout Branch.iO</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C184%252C195%252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252F%252520login%25250ABranch.getInstance%28%29.setIdentity%28%252522your_user_id%252522%29%25250A%25250A%25252F%25252F%252520logout%25250ABranch.getInstance%28%29.logout%28%29&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C184%25252C195%25252C0%29%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252F%25252520login%2525250ABranch.getInstance%28%29.setIdentity%28%25252522your_user_id%25252522%29%2525250A%2525250A%2525252F%2525252F%25252520logout%2525250ABranch.getInstance%28%29.logout%28%29&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1253fd9e9dd3900313a0f21d82ba314d/href">https://medium.com/media/1253fd9e9dd3900313a0f21d82ba314d/href</a></iframe><p><strong>It all about branch.io basic implementation. Please clap, Share and follow my blogs for the latest update.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20d75a32f78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Linking in Android/iOS Part-1]]></title>
            <link>https://medium.com/@gurwindersingh_37022/deep-linking-in-android-ios-part-1-87800b0321d?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/87800b0321d</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[deeplink]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 21:42:06 GMT</pubDate>
            <atom:updated>2020-09-07T10:33:42.609Z</atom:updated>
            <content:encoded><![CDATA[<p>Deep linking is the most common feature almost implemented in all applications. The best Example for Deep linking applications are the following :</p><p><strong>PlayStore/ AppStore</strong> — Download application from the link.</p><p><strong>Google Pay/Play</strong> — Pay/Send money to someone or share reward points.</p><p><strong>Jugnoo/ Uber/Ola Cabs</strong> — Referral &amp; Earn to someone else for download applications or share information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ES8qIMpzxfF5GH-n.png" /></figure><h3><strong>What is deep linking?</strong></h3><p>Deep linking is a concept to link your application with a URL(web content) using specific URL-schemes(pattern). E.g share a specific URL to download the application from the application store or open if it already installs.</p><h3><strong>Most Common SDK to Implement Deep Linking</strong></h3><h3><strong>BRANCH.io</strong></h3><p>Branch.io is the most popular SDK to Implement Deep linking. SDK provides various features like analytics reports of shared links based on platforms(web/iOS/Android) and design page content for advertised about the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*Y-XiaO0QBCjxvTIcSRfZcA.png" /></figure><h3><strong>Steps to Setup in branch.io platforms</strong></h3><p>1. Create a New Application, Option at bottom Left Panel/ Top centric part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*HDyCoDAfyro8smtMqZWc2Q.png" /><figcaption>To create a new application on the dashboard.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*edP2taEYM6F_IVx94R7sIQ.png" /></figure><ul><li>Enter AppName</li><li>Set TimeZone — important for analytic reports.</li></ul><p>2.Switch Application to Test — Live Mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*hPXoo5ZbkhDidyfaPvYVFg.png" /><figcaption>Switch Live/Test Mode</figcaption></figure><p>3. Once the application is created you need to config the application based on the platform checkout below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*t5EV8kPIb4ufM3eyW9gNOg.png" /><figcaption>open Configuration option for config.</figcaption></figure><p><strong>Config Android Application.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSEVujOjcZVnpvucyY_nnw.png" /></figure><p>Set the Android application URL if the application is already live on Store.</p><p><strong>Config iOS Application.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*fR9btexu2qfRGjhKk2oZRw.png" /></figure><h3><strong>Domain in Deeplinking</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*47edqbHYosmTt34crxma5w.png" /><figcaption>Change My Domain to set a custom domain</figcaption></figure><p><strong>Domain? — The domain is similar to package-name or identifier of application to identify and generate a link for a specific domain and click impression according to it.</strong></p><blockquote>Every application in branch.io has a default value of the domain. we can change it by <strong>Change My Domain</strong>.</blockquote><h3><strong>Universal Link</strong></h3><p>Starting with iOS 9, Apple offers Universal Linking functionality, which will open URLs directly into an app, rather than the usual Link -&gt; Safari -&gt; App handoff cycle. This requires some setup, but we do this for you, we just need your Apple App Prefix and your app’s Bundle Identifier.</p><ul><li>Add Bundle Identifier for Universal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BItZz13skICrYKtmOIr5-g.png" /></figure><p>It all about the Branch.io Dashboard setup. In the next article, we discuss coding snippets to implement an application(Android/iOS). Please clap, Share and follow my blogs for the latest update and next part of the implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87800b0321d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON Serialization in Dart/Flutter.]]></title>
            <link>https://medium.com/@gurwindersingh_37022/json-serialization-in-dart-flutter-9835924c488?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9835924c488</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[serialization]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Wed, 12 Aug 2020 21:01:04 GMT</pubDate>
            <atom:updated>2020-08-12T21:01:04.191Z</atom:updated>
            <content:encoded><![CDATA[<p>In Dart GSON/Mochi Serialisation like android is not available, because reflection is disabled in the dart. In Dart, shaking the tree shaking is available for a long time.</p><p>In Dart, JSON Serialization is most relevant like iOS Like using JSONEncoder and JSONDecoder for encoding and decoding data models respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2Cny0qcIJa4Qh1_wgBTZA.png" /></figure><p>JSON Serialisation in Modal Class.</p><p><strong>JSON:</strong></p><pre>{<br>  &quot;user_id&quot;: &quot;USER001&quot;,<br>  &quot;user_email&quot;: &quot;mocgurwinder@gmail.com&quot;<br>}</pre><h3><strong>STEP:</strong></h3><ol><li>Add dependency</li></ol><p>Write the following dependency for JSON serialization in pubspec. file</p><pre>dev_dependencies:<br>  build_runner: &lt;latest_version&gt;<br><strong>  json_serializable: &lt;latest_version&gt;</strong></pre><p>2. Create a model class using <strong>json_serializable </strong>way.</p><pre><strong>part &#39;user.g.dart&#39;;</strong><br><br><strong>@JsonSerializable()</strong><br><br>class User {</pre><pre><strong>@JsonKey(name: &#39;user_id&#39;)</strong>  final String mUserID;</pre><pre><strong>@JsonKey(name: &#39;user_email&#39;)</strong>  final String mUserEmail;</pre><pre>User(this.mUserID, this.mUserEmail);</pre><pre>factory User.fromJson(Map&lt;String, dynamic&gt; json)  =&gt;_$<strong>UserFromJson</strong>(json);<br><br>  Map&lt;String, dynamic&gt; toJson() =&gt; _$<strong>UserToJson</strong>(this);</pre><pre>}</pre><p><strong>Explain:</strong></p><pre><strong>part &#39;user.g.dart&#39;;</strong></pre><p>The above keyword “<strong>part”</strong> is used to define the JSONEncoder Class which helps to Encode the class member with respective keys.</p><p>1: <strong>@JsonSerializable() — used for the class need to serialized i.e in User class.</strong></p><p>2: <strong>@JsonKey() — Used to define the map of parse key with variable.</strong></p><p>3: <strong>UserFromJson — for parse/encode JSON with the class model.</strong></p><p>4: <strong>UserToJson —for decode to JSON.</strong></p><h4>One-time code generation</h4><p>By running flutter pub run build_runner build in the project root, you generate the JSON serialization code for your models whenever they are needed. This triggers a one-time build that goes through the source files, picks the relevant ones, and generates the necessary serialization code for them.</p><h3><strong>How to use?</strong></h3><pre>Map userMap = jsonDecode(jsonString);<br>var user = User.fromJson(userMap); // for jsonstring to DAO<br>print(user.toJson()); // json from DAO</pre><p>Hope, you all clear the JSON Serialization in Dart. For more blogs, Don’t forget to follow/subscribe to my blog and clap for motivation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9835924c488" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigation & Routes Flutter]]></title>
            <link>https://medium.com/@gurwindersingh_37022/navigation-routes-flutter-58ebbcee847a?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/58ebbcee847a</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[flutter-community]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Sun, 05 Jul 2020 13:40:37 GMT</pubDate>
            <atom:updated>2020-07-05T14:06:27.029Z</atom:updated>
            <content:encoded><![CDATA[<p>Navigation is the most important topic in mobile application development. It makes clean and easy development. In Enterprises level application development, it plays a vital role in development, provides less coupling, and understand the complex structure of views with data passing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lvozH0uBHI-jD82BGF9-Xg.png" /></figure><h3>SETUP ROUTES</h3><pre>// MyApp Route<br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      onGenerateRoute: Router.generateRoute,<br>      initialRoute: &quot;/&quot;,<br>      );<br>  }<br>}</pre><pre>// Home Route<br>class Home extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Center(child: Text(&#39;Home&#39;)),<br>    );<br>  }<br>}</pre><pre>// Detail Route<br>class Detail extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Center(child: Text(&#39;Detail&#39;)),<br>    );<br>  }<br>}</pre><h3>CUSTOM HELPER - ROUTER CLASS</h3><p>It helps to route the application based on identifiers. Identifiers are defined in Switch-Case along with corresponding routes e.g Home, Detail etc..</p><blockquote>class Router {</blockquote><blockquote><strong>static Route&lt;dynamic&gt; generateRoute(RouteSettings settings) {</strong><br><strong> switch (settings.name) {</strong><br><strong> case ‘/’:</strong><br> <strong>return</strong> MaterialPageRoute(builder: (_) =&gt; Home());<br><strong> case ‘/detail’:</strong><br> <strong>return</strong> MaterialPageRoute(builder: (_) =&gt; Detail());<br><strong> default:</strong><br> <strong>return</strong> MaterialPageRoute(<br> builder: (_) =&gt; Scaffold(<br> body: Center(<br> child: Text(‘No route defined for ${settings.name}’)),<br> ));<br> }<br> }</blockquote><blockquote>}</blockquote><h3>How application navigate to other routes?</h3><p>In Flutter Navigator predefined class is used to navigate the route.</p><h4>PushedNamed — Member function with the input of context and Route Name.</h4><h4>E.g :</h4><p>Navigator.pushNamed(context, “/detail”);</p><p>I Hope, your answer is defined in the blog. Helper class easy to make clean routing in a flutter. It&#39;s a basic example, used to navigate the route. For more examples, and interesting topic. Follow + Subscribe + CLAP the blog for the latest update about blogs.</p><blockquote><strong>Linked in:</strong></blockquote><blockquote>www.linkedin.com/in/mocgurwinder</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58ebbcee847a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BLoC Architecture Flutter]]></title>
            <link>https://medium.com/@gurwindersingh_37022/bloc-architecture-flutter-91798ec6d428?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/91798ec6d428</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-bloc]]></category>
            <category><![CDATA[better-programming]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[hybrid-app-development]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Tue, 12 May 2020 00:17:43 GMT</pubDate>
            <atom:updated>2020-05-12T00:20:09.260Z</atom:updated>
            <content:encoded><![CDATA[<p>For a better understanding of code, architecture plays a vital role to understand the level of development or developer knowledge. In most popular languages, project management resources easily available in the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*h6eq0lRpiCCRQUghm9ep2A.png" /></figure><h3><strong>Quick Setup</strong></h3><p>pubspec.yaml</p><p><strong>flutter_bloc:^</strong></p><h3>Understanding the Concept of BLoC pattern</h3><p>It takes streams of input and provides streams of the state which are used as output.</p><p>Example:</p><h3>BlocProvider</h3><p>Blocprovider is flutter widget which provides a bloc to its child via BlocProvider.of(context)</p><p>Snippet:</p><blockquote>BlocProvider(<br> builder: (BuildContext context) =&gt; BlocA(),<br> child: ChildA(),<br>);</blockquote><p>Let Practical Example to Explain:</p><p><em>1.Repository — For Api Call (Download ASYNC/ Future call for download data)</em></p><p><em>2.DataSource — For Data Provider (Data Model taking data from Repository and parse).</em></p><p>3. Bloc — Stream of Event Data.</p><h3>1. Data Model:</h3><blockquote><strong>class ItemModel </strong>{<br> <strong>int </strong>_page;<br> <strong>int </strong>_total_results;<br> <strong>int </strong>_total_pages;<br> <strong>List</strong>&lt;<strong>_Result</strong>&gt; _results = [];</blockquote><blockquote><strong>ItemModel</strong>.fromJson(<strong>Map</strong>&lt;<strong>String</strong>, <strong>dynamic</strong>&gt; parsedJson) {<br> print(parsedJson[‘results’].length);<br> _page = parsedJson[‘page’];<br> _total_results = parsedJson[‘total_results’];<br> _total_pages = parsedJson[‘total_pages’];<br> <strong>List</strong>&lt;<strong>_Result</strong>&gt; temp = [];<br> <strong>for </strong>(<strong>int </strong>i = 0; i &lt; parsedJson[‘results’].length; i++) {<br> <strong>_Result </strong>result = _Result(parsedJson[‘results’][i]);<br> temp.add(result);<br> }<br> _results = temp;<br> }</blockquote><blockquote><strong>List</strong>&lt;<strong>_Result</strong>&gt; <strong>get </strong>results =&gt; _results;</blockquote><blockquote><strong>int get </strong>total_pages =&gt; _total_pages;</blockquote><blockquote><strong>int get </strong>total_results =&gt; _total_results;</blockquote><blockquote><strong>int get </strong>page =&gt; _page;<br>}</blockquote><h3>Data Source / ASYNC</h3><blockquote><strong>import </strong>‘dart:async’;<br><strong>import </strong>‘package:http/http.dart’ <strong>show Client</strong>;<br><strong>import </strong>‘dart:convert’;<br><strong>import </strong>‘../models/item_model.dart’;</blockquote><blockquote><strong>class MovieApiProvider </strong>{<br> <strong>Client </strong>client = Client();</blockquote><blockquote><strong>Future</strong>&lt;<strong>ItemModel</strong>&gt; fetchMovieList() <strong>async </strong>{<br> print(“entered”);<br> <strong>final </strong>response = <strong>await </strong>client<br> .get(“&lt;API SOURCE &gt;”);<br> print(response.body.toString());<br> <strong>if </strong>(response.statusCode == 200) {<br> // If the call to the server was successful, parse the JSON<br> <strong>return </strong>ItemModel.fromJson(json.decode(response.body));<br> } <strong>else </strong>{<br> // If that call was not successful, throw an error.<br> <strong>throw </strong>Exception(‘Failed to load post’);<br> }<br> }<br>}</blockquote><h3><strong>BLoc (Bussiness Logic)</strong></h3><p>Fetch Data from DataSource and provide to Stream of UI.</p><blockquote><strong>import </strong>‘../resources/repository.dart’;<br><strong>import </strong>‘package:rxdart/rxdart.dart’;<br><strong>import </strong>‘../models/item_model.dart’;</blockquote><blockquote><strong>class MoviesBloc </strong>{<br> <strong>final </strong>_repository = Repository();<br> <strong>final </strong>_moviesFetcher = PublishSubject&lt;<strong>ItemModel</strong>&gt;();</blockquote><blockquote><strong>Observable</strong>&lt;<strong>ItemModel</strong>&gt; <strong>get </strong>allMovies =&gt; _moviesFetcher.stream;</blockquote><blockquote>fetchAllMovies() <strong>async </strong>{<br> <strong>ItemModel </strong>itemModel = <strong>await </strong>_repository.fetchAllMovies();<br> _moviesFetcher.sink.add(itemModel);<br> }</blockquote><blockquote>dispose() {<br> _moviesFetcher.close();<br> }<br>}</blockquote><blockquote><strong>final </strong>bloc = MoviesBloc();</blockquote><h3>Bind BLoC with UI</h3><blockquote><strong>class MovieList extends StatelessWidget </strong>{<br> @override<br> <strong>Widget </strong>build(<strong>BuildContext </strong>context) {<br> bloc.fetchAllMovies();<br> <strong>return </strong>Scaffold(<br> appBar: AppBar(<br> title: Text(‘Popular Movies’),<br> ),<br> body: StreamBuilder(<br> stream: bloc.allMovies,<br> builder: (context, <strong>AsyncSnapshot</strong>&lt;<strong>ItemModel</strong>&gt; snapshot) {<br> <strong>if </strong>(snapshot.hasData) {<br> <strong>return </strong>buildList(snapshot);<br> } <strong>else if </strong>(snapshot.hasError) {<br> <strong>return </strong>Text(snapshot.error.toString());<br> }<br> <strong>return </strong>Center(child: CircularProgressIndicator());<br> },<br> ),<br> );<br> }</blockquote><h3><strong>Most Important Part of BLoC</strong></h3><blockquote><strong>StreamBuilder(<br> stream: bloc.allMovies,<br></strong> <strong>builder: (context, AsyncSnapshot&lt;ItemModel&gt; snapshot) {</strong><br><strong> if (snapshot.hasData) {}</strong><br><strong>&lt;SnapShot return object of each ItemMode&gt;</strong><br><strong>}))</strong></blockquote><p>Above snippet used for output event streaming and update View state. <strong>StreamBuilder which will listen to the incoming streams and update the UI accordingly.</strong></p><p>So we have hit the end of this article. Great job folks for holding on till the end. I hope you like this article. If you have any doubts or questions do connect with me at <a href="https://www.linkedin.com/in/mocgurwinder/"><strong>LinkedIn</strong></a><strong>. </strong>Do appreciate the article with some claps and comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91798ec6d428" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Image Picker using  Camera and Gallery.]]></title>
            <link>https://medium.com/@gurwindersingh_37022/android-image-picker-using-camera-and-gallery-63da87e9efcd?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/63da87e9efcd</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[utilities]]></category>
            <category><![CDATA[dev]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 20:57:50 GMT</pubDate>
            <atom:updated>2020-04-22T22:10:10.064Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Image Picker using Camera and Gallery.</h3><p>Implementation Utility of Custom Camera using Camera-X and Gallery in android and upload to server/ Firebase. It helps the developer to reduce the time of implementation, just clone and use it in the project.</p><h3><strong>In LockDown Don’t Panic, It&#39;s a long session.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZYdJ-YJtXsIaXlwdomMfOQ.png" /></figure><blockquote><strong>For Camera and Open Gallery:</strong></blockquote><pre>(<em>activity </em><strong>as </strong>MainActivity).openCamera()</pre><pre>(<em>activity </em><strong>as </strong>MainActivity).openGallery()</pre><blockquote><strong>ImagePickerDialog — For ImagePicker Dialog</strong></blockquote><pre><strong>class </strong>ImagePickerDialog : DialogFragment() {<br><br>    <strong>companion object </strong>{<br>        <strong>fun </strong>newInstance() = ImagePickerDialog()<br>    }<br><br>    <strong>override fun </strong>onCreateView(<br>            inflater: LayoutInflater, container: ViewGroup?,<br>            savedInstanceState: Bundle?<br>    ): View {<br>        <strong>return </strong>inflater.inflate(R.layout.<em>image_picker_dialog</em>,  container, <strong>false</strong>)<br>    }<br><br>    <strong>override fun </strong>onViewCreated(view: View, savedInstanceState: Bundle?) {<br>        <strong>super</strong>.onViewCreated(view, savedInstanceState)<br>        initViews()<br>    }<br><br>    <strong>private fun </strong>initViews() {<br>        btCamera.setOnClickListener <strong>{<br>            when </strong>(<em>activity</em>) {<br>                <strong>is </strong>MainActivity -&gt; {<br>                    (<em>activity </em><strong>as </strong>MainActivity).openCamera()<br>                    dismiss()<br>                }<br>            }<br>        <strong>}<br>        </strong>btGallery.setOnClickListener <strong>{<br>            when </strong>(<em>activity</em>) {<br>                <strong>is </strong>MainActivity -&gt; {<br>                    (<em>activity </em><strong>as </strong>MainActivity).openGallery()<br>                    dismiss()<br>                }<br>            }<br>        <strong>}<br>    </strong>}<br>}</pre><blockquote>Activity to implement Util’s</blockquote><pre>onActivityResult - For getting callback of permission&#39;s and data from intent.</pre><blockquote><strong>In MainActivity.kt</strong></blockquote><pre><strong>class </strong>MainActivity : BaseActivity() {<br><br>    @Inject<br>    <strong>lateinit var viewModel</strong>: MainViewModel<br><br>    <strong>private var mFilePathUri</strong>: Uri? = <strong>null<br><br>    private lateinit var mImagePickerDialog</strong>: ImagePickerDialog<br><br>    <strong>override fun </strong>onCreate(savedInstanceState: Bundle?) {<br>        <strong>super</strong>.onCreate(savedInstanceState)<br>        setContentView(R.layout.<em>activity_main</em>)<br>        setViewModel()<br>        initViews()<br>    }<br><br>    <strong>private fun </strong>initViews() {<br>        <em>// Adding click listener to Choose image button.¬<br>        </em>btChooseImage!!.setOnClickListener <strong>{<br>            </strong>getImagePicker()<br>        <strong>}<br>        </strong><em>// Adding click listener to Upload image button.<br>        </em>btUploadImage!!.setOnClickListener <strong>{<br>            </strong><em>// Calling method to upload selected image on Firebase storage.<br>            </em><strong>viewModel</strong>.uploadImageFileToFirebaseStorage(<br>                    pFilePathUri = <strong>mFilePathUri</strong>,<br>                    pImageNameEditText = imageNameEditText.<em>text</em>.toString()<br>            )<br>        <strong>}<br>        </strong>btDisplayImages!!.setOnClickListener <strong>{<br>            val </strong>intent = Intent(<strong>this</strong>@MainActivity, DisplayImagesActivity::<strong>class</strong>.<em>java</em>)<br>            startActivity(intent)<br>        <strong>}<br>    </strong>}<br><br>    <strong>override fun </strong>onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {<br>        <strong>super</strong>.onActivityResult(requestCode, resultCode, data)<br>        <strong>if </strong>(requestCode == <em>Image_Request_Code<br>                </em>&amp;&amp; resultCode == Activity.<em>RESULT_OK<br>                </em>&amp;&amp; data != <strong>null<br>                </strong>&amp;&amp; data.<em>data </em>!= <strong>null<br>        </strong>) {<br>            <strong>mFilePathUri </strong>= data.<em>data<br>            </em><strong>try </strong>{ <em>// Getting selected image into Bitmap.<br>                </em><strong>val </strong>bitmap = MediaStore.Images.Media.getBitmap(<em>contentResolver</em>, <strong>mFilePathUri</strong>)<br>                showImageView!!.setImageBitmap(bitmap)<br>                showImageView.<em>visibility</em>= View.<em>VISIBLE<br>                </em>btChooseImage!!.<em>text </em>= getString(R.string.<em>image_selected</em>)<br>            } <strong>catch </strong>(e: IOException) {<br>                e.printStackTrace()<br>            }<br>        }<br><br>    }<br><br>    <strong>private fun </strong>setViewModel() {<br>        <strong>viewModel </strong>= ViewModelProvider(<strong>this</strong>, <strong>mViewModelFactory</strong>).get(MainViewModel::<strong>class</strong>.<em>java</em>)<br>    }<br><br>    <strong>fun </strong>openGallery() {<br>        ImageUtils.newInstance().openGallery(<strong>this</strong>)<br>    }<br><br>    <strong>fun </strong>openCamera() {<br>        startActivityForResult(Intent(<strong>this</strong>, CamerActivity::<strong>class</strong>.<em>java</em>), Constants.<strong>Image_Request_Code</strong>)<br>    }<br><br>    <strong>private fun </strong>getImagePicker() {<br>        <strong>when </strong>(::<strong>mImagePickerDialog</strong>.<em>isInitialized</em>) {<br>            <strong>false </strong>-&gt; <strong>mImagePickerDialog </strong>= ImagePickerDialog.newInstance()<br>        }<br>        <strong>when </strong>(!<strong>mImagePickerDialog</strong>.<em>isAdded</em>) {<br>            <strong>true </strong>-&gt; <strong>mImagePickerDialog</strong>.show(<em>supportFragmentManager</em>, <strong>mImagePickerDialog</strong>.<em>javaClass</em>.<em>simpleName</em>)<br>        }<br>    }<br>}</pre><blockquote><strong>For CamerActivity — For open camera activity include both Camera Fragment and Open Gallery:</strong></blockquote><blockquote><strong>In CamerActivity.Kt</strong></blockquote><pre><strong>const val </strong><em>KEY_EVENT_ACTION </em>= <strong>&quot;key_event_action&quot;<br>const val </strong><em>KEY_EVENT_EXTRA </em>= <strong>&quot;key_event_extra&quot;<br>private const val </strong><em>IMMERSIVE_FLAG_TIMEOUT </em>= 500L<br><br><br><strong>class </strong>CamerActivity : AppCompatActivity() {<br>    <strong>private lateinit var container</strong>: FrameLayout<br><br>    <strong>override fun </strong>onCreate(savedInstanceState: Bundle?) {<br>        <strong>super</strong>.onCreate(savedInstanceState)<br>        setContentView(R.layout.<em>activity_camera_main</em>)<br>        <strong>container </strong>= findViewById(R.id.<em>fragment_container</em>)<br>    }<br><br>    <strong>override fun </strong>onResume() {<br>        <strong>super</strong>.onResume()<br>        <strong>container</strong>.postDelayed(<strong>{ container</strong>.<em>systemUiVisibility </em>= <em>FLAGS_FULLSCREEN </em><strong>}</strong>, <em>IMMERSIVE_FLAG_TIMEOUT</em>)<br>    }<br><br>    <em>/** When key down event is triggered, relay it via local broadcast so fragments can handle it */<br>    </em><strong>override fun </strong>onKeyDown(keyCode: Int, event: KeyEvent): Boolean {<br>        <strong>return when </strong>(keyCode) {<br>            KeyEvent.<em>KEYCODE_VOLUME_DOWN </em>-&gt; {<br>                <strong>val </strong>intent = Intent(<em>KEY_EVENT_ACTION</em>).<em>apply </em><strong>{ </strong>putExtra(<em>KEY_EVENT_EXTRA</em>, keyCode) <strong>}<br>                </strong>LocalBroadcastManager.getInstance(<strong>this</strong>).sendBroadcast(intent)<br>                <strong>true<br>            </strong>}<br>            <strong>else </strong>-&gt; <strong>super</strong>.onKeyDown(keyCode, event)<br>        }<br>    }<br>}</pre><pre><strong>val </strong><em>EXTENSION_WHITELIST </em>= <em>arrayOf</em>(<strong>&quot;JPG&quot;</strong>, <strong>&quot;PNG&quot;</strong>)<br><br><strong>class </strong>GalleryFragment <strong>internal constructor</strong>() : Fragment() {<br><br>    <strong>private val args</strong>: GalleryFragmentArgs <strong>by </strong><em>navArgs</em>()<br>    <strong>private lateinit var mediaList</strong>: MutableList&lt;File&gt;<br><br>    <strong>inner class </strong>MediaPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm, <em>BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT</em>) {<br>        <strong>override fun </strong>getCount(): Int = <strong>mediaList</strong>.<strong>size<br>        override fun </strong>getItem(position: Int): Fragment = PhotoFragment.create(<strong>mediaList</strong>[position])<br>        <strong>override fun </strong>getItemPosition(obj: Any): Int = <em>POSITION_NONE<br>    </em>}<br><br>    <strong>override fun </strong>onCreate(savedInstanceState: Bundle?) {<br>        <strong>super</strong>.onCreate(savedInstanceState)<br>        <em>retainInstance </em>= <strong>true<br>        val </strong>rootDirectory = File(<strong>args</strong>.<em>rootDirectory</em>)<br>        <strong>mediaList </strong>= rootDirectory.listFiles <strong>{ </strong>file <strong>-&gt;<br>            </strong><em>EXTENSION_WHITELIST</em>.<em>contains</em>(file.<em>extension</em>.<em>toUpperCase</em>(Locale.<em>ROOT</em>))<br>        <strong>}</strong>?.<em>sortedDescending</em>()?.<em>toMutableList</em>() ?: <em>mutableListOf</em>()<br>    }<br><br>    <strong>override fun </strong>onCreateView(<br>            inflater: LayoutInflater,<br>            container: ViewGroup?,<br>            savedInstanceState: Bundle?<br>    ): View? = inflater.inflate(R.layout.<em>fragment_gallery</em>, container, <strong>false</strong>)<br><br>    <strong>override fun </strong>onViewCreated(view: View, savedInstanceState: Bundle?) {<br>        <strong>super</strong>.onViewCreated(view, savedInstanceState)<br>        <strong>if </strong>(<strong>mediaList</strong>.isEmpty()) {<br>            view.findViewById&lt;ImageButton&gt;(R.id.<em>delete_button</em>).<em>isEnabled </em>= <strong>false<br>            </strong>view.findViewById&lt;ImageButton&gt;(R.id.<em>share_button</em>).<em>isEnabled </em>= <strong>false<br>        </strong>}<br>        photo_view_pager.<em>apply </em><strong>{<br>            </strong><em>offscreenPageLimit </em>= 2<br>            <em>adapter </em>= MediaPagerAdapter(<em>childFragmentManager</em>)<br>        <strong>}<br><br>        if </strong>(Build.VERSION.<em>SDK_INT </em>&gt;= Build.VERSION_CODES.<em>P</em>) {<br>            cutout_safe_area.<em>padWithDisplayCutout</em>()<br>        }<br><br>        back_button.setOnClickListener <strong>{<br>            </strong>Navigation.findNavController(requireActivity(), R.id.<em>fragment_container</em>).navigateUp()<br>        <strong>}<br>        </strong>share_button.setOnClickListener <strong>{<br>            mediaList</strong>.<em>getOrNull</em>(photo_view_pager.<em>currentItem</em>)?.<em>let </em><strong>{ </strong>mediaFile <strong>-&gt;<br>                val </strong>intent = Intent().<em>apply </em><strong>{<br>                    val </strong>mediaType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(mediaFile.<em>extension</em>)<br>                    <strong>val </strong>uri = FileProvider.getUriForFile(<br>                            view.<em>context</em>,<br>                            BuildConfig.<em>APPLICATION_ID </em>+ <strong>&quot;.provider&quot;</strong>,<br>                            mediaFile<br>                    )<br>                    putExtra(Intent.<em>EXTRA_STREAM</em>, uri)<br>                    <em>type </em>= mediaType<br>                    <em>action </em>= Intent.<em>ACTION_SEND<br>                    flags </em>= Intent.<em>FLAG_GRANT_READ_URI_PERMISSION<br>                </em><strong>}<br>                </strong>startActivity(Intent.createChooser(intent, getString(R.string.<em>share_hint</em>)))<br>            <strong>}<br>        }<br><br>        </strong>delete_button.setOnClickListener <strong>{<br>            mediaList</strong>.<em>getOrNull</em>(photo_view_pager.<em>currentItem</em>)?.<em>let </em><strong>{ </strong>mediaFile <strong>-&gt;<br>                </strong>AlertDialog.Builder(view.<em>context</em>, android.R.style.<em>Theme_Material_Dialog</em>)<br>                        .setTitle(getString(R.string.<em>delete_title</em>))<br>                        .setMessage(getString(R.string.<em>delete_dialog</em>))<br>                        .setIcon(android.R.drawable.<em>ic_dialog_alert</em>)<br>                        .setPositiveButton(android.R.string.<em>yes</em>) <strong>{ </strong>_, _ <strong>-&gt;<br>                            </strong>mediaFile.delete()<br>                            MediaScannerConnection.scanFile(<br>                                    view.<em>context</em>,<br>                                    <em>arrayOf</em>(mediaFile.<em>absolutePath</em>),<br>                                    <strong>null</strong>,<br>                                    <strong>null<br>                            </strong>)<br>                            <strong>mediaList</strong>.removeAt(photo_view_pager.<em>currentItem</em>)<br>                            photo_view_pager.<em>adapter</em>?.notifyDataSetChanged()<br>                            <em>// If all photos have been deleted, return to camera<br>                            </em><strong>if </strong>(<strong>mediaList</strong>.isEmpty()) {<br>                                Navigation.findNavController(requireActivity(), R.id.<em>fragment_container</em>).navigateUp()<br>                            }<br>                        <strong>}<br>                        </strong>.setNegativeButton(android.R.string.<em>no</em>, <strong>null</strong>)<br>                        .create().<em>showImmersive</em>()<br>            <strong>}<br>        }<br>    </strong>}<br>}</pre><blockquote><strong>Camera Fragment for Implement Camera using Camera X</strong></blockquote><pre><strong>typealias </strong>LumaListener = (luma: Double) -&gt; Unit<br><br><strong>class </strong>CameraFragment : Fragment() {<br><br>    <strong>private lateinit var mContainer</strong>: ConstraintLayout<br>    <strong>private lateinit var mOutputDirectory</strong>: File<br>    <strong>private lateinit var mLocalBroadcastManager</strong>: LocalBroadcastManager<br><br>    <strong>private var mDisplayId</strong>: Int = -1<br>    <strong>private var mDefaultLen</strong>: Int = CameraSelector.<em>LENS_FACING_BACK<br>    </em><strong>private var mCameraPreview</strong>: Preview? = <strong>null<br>    private var mImageCapture</strong>: ImageCapture? = <strong>null<br>    private var mImageAnalyzer</strong>: ImageAnalysis? = <strong>null<br>    private var mCamera</strong>: Camera? = <strong>null<br><br>    private val displayManager by </strong><em>lazy </em><strong>{<br>        </strong>requireContext().getSystemService(Context.<em>DISPLAY_SERVICE</em>) <strong>as </strong>DisplayManager<br>    <strong>}<br><br>    private lateinit var cameraExecutor</strong>: ExecutorService<br><br>    <em>/** Volume down button receiver used to trigger shutter */<br>    </em><strong>private val volumeDownReceiver </strong>= <strong>object </strong>: BroadcastReceiver() {<br>        <strong>override fun </strong>onReceive(context: Context, intent: Intent) {<br>            <strong>when </strong>(intent.getIntExtra(<em>KEY_EVENT_EXTRA</em>, KeyEvent.<em>KEYCODE_UNKNOWN</em>)) {<br>                <em>// When the volume down button is pressed, simulate a shutter button click<br>                </em>KeyEvent.<em>KEYCODE_VOLUME_DOWN </em>-&gt; {<br>                    camera_capture_button.<em>simulateClick</em>()<br>                }<br>            }<br>        }<br>    }<br><br>    <em>/**<br>     * We need a display listener for orientation changes that do not trigger a configuration<br>     * change, for example if we choose to override config change in manifest or for 180-degree<br>     * orientation changes.<br>     */<br>    </em><strong>private val displayListener </strong>= <strong>object </strong>: DisplayManager.DisplayListener {<br>        <strong>override fun </strong>onDisplayAdded(displayId: Int) = Unit<br>        <strong>override fun </strong>onDisplayRemoved(displayId: Int) = Unit<br>        <strong>override fun </strong>onDisplayChanged(displayId: Int) = <em>view</em>?.<em>let </em><strong>{ </strong>view <strong>-&gt;<br>            if </strong>(displayId == <strong>this</strong>@CameraFragment.<strong>mDisplayId</strong>) {<br>                Log.d(Constants.<strong>TAG</strong>, <strong>&quot;Rotation changed: ${</strong>view.<em>display</em>.<em>rotation</em><strong>}&quot;</strong>)<br>                <strong>mImageCapture</strong>?.<em>targetRotation </em>= view.<em>display</em>.<em>rotation<br>                </em><strong>mImageAnalyzer</strong>?.<em>targetRotation </em>= view.<em>display</em>.<em>rotation<br>            </em>}<br>        <strong>} </strong>?: Unit<br>    }<br><br>    <strong>override fun </strong>onResume() {<br>        <strong>super</strong>.onResume()<br>        <strong>if </strong>(!Constants.hasPermissions(requireContext())) {<br>            Navigation.findNavController(<br>                    requireActivity(),<br>                    R.id.<em>fragment_container</em>).navigate(<br>                    CameraFragmentDirections.actionCameraToPermissions()<br>            )<br>        }<br>    }<br><br>    <strong>override fun </strong>onDestroyView() {<br>        <strong>super</strong>.onDestroyView()<br>        <strong>cameraExecutor</strong>.shutdown()<br>        <strong>mLocalBroadcastManager</strong>.unregisterReceiver(<strong>volumeDownReceiver</strong>)<br>        <strong>displayManager</strong>.unregisterDisplayListener(<strong>displayListener</strong>)<br>    }<br><br>    <strong>override fun </strong>onCreateView(<br>            inflater: LayoutInflater,<br>            container: ViewGroup?,<br>            savedInstanceState: Bundle?): View? =<br>            inflater.inflate(<br>                    R.layout.<em>fragment_camera</em>,<br>                    container,<br>                    <strong>false<br>            </strong>)<br><br>    <strong>private fun </strong>setGalleryThumbnail(uri: Uri) {<br>        photo_view_button.post <strong>{<br>            </strong>photo_view_button.<em>setPadding</em>(<em>resources</em>.getDimension(R.dimen.<em>stroke_small</em>).toInt())<br>            Glide.with(photo_view_button)<br>                    .load(uri)<br>                    .apply(RequestOptions.circleCropTransform())<br>                    .into(photo_view_button)<br>        <strong>}<br>    </strong>}<br><br>    @SuppressLint(<strong>&quot;MissingPermission&quot;</strong>)<br>    <strong>override fun </strong>onViewCreated(view: View, savedInstanceState: Bundle?) {<br>        <strong>super</strong>.onViewCreated(view, savedInstanceState)<br>        <strong>mContainer </strong>= view <strong>as </strong>ConstraintLayout<br>        <em>// Initialize our background executor<br>        </em><strong>cameraExecutor </strong>= Executors.newSingleThreadExecutor()<br>        <strong>mLocalBroadcastManager </strong>= LocalBroadcastManager.getInstance(view.<em>context</em>)<br>        <em>// Set up the intent filter that will receive events from our main activity<br>        </em><strong>val </strong>filter = IntentFilter().<em>apply </em><strong>{ </strong>addAction(<em>KEY_EVENT_ACTION</em>) <strong>}<br>        mLocalBroadcastManager</strong>.registerReceiver(<strong>volumeDownReceiver</strong>, filter)<br>        <em>// Every time the orientation of device changes, update rotation for use cases<br>        </em><strong>displayManager</strong>.registerDisplayListener(<strong>displayListener</strong>, <strong>null</strong>)<br>        <em>// Determine the output directory<br>        </em><strong>mOutputDirectory </strong>= Constants.getOutputDirectory(requireContext())<br>        <em>// Wait for the views to be properly laid out<br>        </em>view_finder.post <strong>{<br>            mDisplayId </strong>= view_finder.<em>display</em>.<em>displayId<br>            </em>updateCameraUi()<br>            bindCameraUseCases()<br>        <strong>}<br>    </strong>}<br><br>    <strong>override fun </strong>onConfigurationChanged(newConfig: Configuration) {<br>        <strong>super</strong>.onConfigurationChanged(newConfig)<br>        updateCameraUi()<br>    }<br><br>    <strong>private fun </strong>setUpPinchToZoom() {<br>        <strong>val </strong>listener = <strong>object </strong>: ScaleGestureDetector.SimpleOnScaleGestureListener() {<br>            <strong>override fun </strong>onScale(detector: ScaleGestureDetector): Boolean {<br>                <strong>val </strong>scale = <strong>mCamera</strong>!!.<em>cameraInfo</em>.<em>zoomState</em>.<em>value</em>!!.<em>zoomRatio </em>* detector.<em>scaleFactor<br>                </em><strong>mCamera</strong>!!.<em>cameraControl</em>.setZoomRatio(scale)<br>                <strong>return true<br>            </strong>}<br>        }<br><br>        <strong>val </strong>scaleGestureDetector = ScaleGestureDetector(<em>context</em>, listener)<br>        view_finder.setOnTouchListener <strong>{ </strong>_, event <strong>-&gt;<br>            </strong>scaleGestureDetector.onTouchEvent(event)<br>            <strong>return</strong>@setOnTouchListener <strong>true<br>        }<br>    </strong>}<br><br>    <strong>private fun </strong>bindCameraUseCases() {<br>        <strong>val </strong>metrics = DisplayMetrics().<em>also </em><strong>{ </strong>view_finder.<em>display</em>.getRealMetrics(<strong>it</strong>) <strong>}<br>        </strong>Log.d(Constants.<strong>TAG</strong>, <strong>&quot;Screen metrics: ${</strong>metrics.<strong>widthPixels} x ${</strong>metrics.<strong>heightPixels}&quot;</strong>)<br>        <strong>val </strong>screenAspectRatio = aspectRatio(metrics.<strong>widthPixels</strong>, metrics.<strong>heightPixels</strong>)<br>        Log.d(Constants.<strong>TAG</strong>, <strong>&quot;Preview aspect ratio: $</strong>screenAspectRatio<strong>&quot;</strong>)<br>        <strong>val </strong>rotation = view_finder.<em>display</em>.<em>rotation<br>        // Bind the CameraProvider to the LifeCycleOwner<br>        </em><strong>val </strong>cameraSelector = CameraSelector.Builder().requireLensFacing(<strong>mDefaultLen</strong>).build()<br>        <strong>val </strong>cameraProviderFuture = ProcessCameraProvider.getInstance(requireContext())<br>        cameraProviderFuture.addListener(<em>Runnable </em><strong>{<br>            val </strong>cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()<br>            <strong>mCameraPreview </strong>= Preview.Builder()<br>                    .setTargetAspectRatio(screenAspectRatio)<br>                    .setTargetRotation(rotation)<br>                    .build()<br>            <em>// ImageCapture<br>            </em><strong>mImageCapture </strong>= ImageCapture.Builder()<br>                    .setCaptureMode(ImageCapture.<em>CAPTURE_MODE_MINIMIZE_LATENCY</em>)<br>                    .setTargetAspectRatio(screenAspectRatio)<br>                    .setTargetRotation(rotation)<br>                    .build()<br>            <em>// ImageAnalysis<br>            </em><strong>mImageAnalyzer </strong>= ImageAnalysis.Builder()<br>                    .setTargetAspectRatio(screenAspectRatio)<br>                    .setTargetRotation(rotation)<br>                    .build()<br>                    .<em>also </em><strong>{<br>                        it</strong>.setAnalyzer(<strong>cameraExecutor</strong>, LuminosityAnalyzer <strong>{ </strong>luma <strong>-&gt;<br>                            </strong>Log.d(Constants.<strong>TAG</strong>, <strong>&quot;Average luminosity: $</strong>luma<strong>&quot;</strong>)<br>                        <strong>}</strong>)<br>                    <strong>}<br>            </strong>cameraProvider.unbindAll()<br>            <strong>try </strong>{<br>                <strong>mCamera </strong>= cameraProvider.bindToLifecycle(<br>                        <strong>this</strong>,<br>                        cameraSelector,<br>                        <strong>mCameraPreview</strong>,<br>                        <strong>mImageCapture</strong>,<br>                        <strong>mImageAnalyzer<br>                </strong>)<br>                <strong>mCameraPreview</strong>?.setSurfaceProvider(view_finder.createSurfaceProvider(<strong>mCamera</strong>?.<em>cameraInfo</em>))<br>                setUpPinchToZoom()<br>            } <strong>catch </strong>(exc: Exception) {<br>                Log.e(Constants.<strong>TAG</strong>, <strong>&quot;Use case binding failed&quot;</strong>, exc)<br>            }<br>        <strong>}</strong>, ContextCompat.getMainExecutor(requireContext()))<br>    }<br><br>    <strong>private fun </strong>aspectRatio(width: Int, height: Int): Int {<br>        <strong>val </strong>previewRatio = <em>max</em>(width, height).toDouble() / <em>min</em>(width, height)<br>        <strong>if </strong>(<em>abs</em>(previewRatio - <em>RATIO_4_3_VALUE</em>) &lt;= <em>abs</em>(previewRatio - <em>RATIO_16_9_VALUE</em>)) {<br>            <strong>return </strong>AspectRatio.<em>RATIO_4_3<br>        </em>}<br>        <strong>return </strong>AspectRatio.<em>RATIO_16_9<br>    </em>}<br><br>    <em>/** Method used to re-draw the camera UI controls, called every time configuration changes. */<br>    </em><strong>private fun </strong>updateCameraUi() {<br>        <em>lifecycleScope</em>.<em>launch</em>(Dispatchers.<strong>IO</strong>) <strong>{<br>            mOutputDirectory</strong>.listFiles <strong>{ </strong>file <strong>-&gt; </strong><em>EXTENSION_WHITELIST</em>.<em>contains</em>(file.<em>extension</em>.<em>toUpperCase</em>(Locale.<em>ROOT</em>)) <strong>}</strong>?.<em>max</em>()?.<em>let </em><strong>{ </strong>setGalleryThumbnail(Uri.fromFile(<strong>it</strong>)) <strong>}<br>        }<br>        </strong><em>// Listener for button used to capture photo<br>        </em>camera_capture_button.setOnClickListener <strong>{<br>            mImageCapture</strong>?.<em>let </em><strong>{ </strong>imageCapture <strong>-&gt;<br>                </strong><em>// Create output file to hold the image<br>                </em><strong>val </strong>photoFile = createFile(<strong>mOutputDirectory</strong>, <em>FILENAME</em>, <em>PHOTO_EXTENSION</em>)<br>                <em>// Setup image capture metadata<br>                </em><strong>val </strong>metadata = Metadata().<em>apply </em><strong>{<br>                    </strong><em>// Mirror image when using the front camera<br>                    isReversedHorizontal </em>= <strong>mDefaultLen </strong>== CameraSelector.<em>LENS_FACING_FRONT<br>                </em><strong>}<br>                </strong><em>// Create output options object which contains file + metadata<br>                </em><strong>val </strong>outputOptions = ImageCapture.OutputFileOptions.Builder(photoFile)<br>                        .setMetadata(metadata)<br>                        .build()<br>                <em>// Setup image capture listener which is triggered after photo has been taken<br>                </em>imageCapture.takePicture(<br>                        outputOptions,<br>                        <strong>cameraExecutor</strong>,<br>                        <strong>object </strong>: ImageCapture.OnImageSavedCallback {<br>                            <strong>override fun </strong>onError(exc: ImageCaptureException) {<br>                                Log.e(Constants.<strong>TAG</strong>, <strong>&quot;Photo capture failed: ${</strong>exc.<strong>message}&quot;</strong>, exc)<br>                            }<br><br>                            <strong>override fun </strong>onImageSaved(output: ImageCapture.OutputFileResults) {<br>                                <strong>val </strong>savedUri = output.<em>savedUri </em>?: Uri.fromFile(photoFile)<br>                                Log.d(Constants.<strong>TAG</strong>, <strong>&quot;Photo capture succeeded: $</strong>savedUri<strong>&quot;</strong>)<br>                                <em>activity</em>?.<em>intent</em>?.<em>data </em>= savedUri<br>                                <em>activity</em>?.setResult(Activity.<em>RESULT_OK</em>, <em>activity</em>?.<em>intent</em>)<br>                                <em>activity</em>?.finish()<br>                                <strong>if </strong>(Build.VERSION.<em>SDK_INT </em>&gt;= Build.VERSION_CODES.<em>M</em>) {<br>                                    setGalleryThumbnail(savedUri)<br>                                }<br>                                <strong>if </strong>(Build.VERSION.<em>SDK_INT </em>&lt; Build.VERSION_CODES.<em>N</em>) {<br>                                    requireActivity().sendBroadcast(Intent(android.hardware.Camera.<em>ACTION_NEW_PICTURE</em>, savedUri))<br>                                }<br>                                <strong>val </strong>mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(savedUri.<em>toFile</em>().<em>extension</em>)<br>                                MediaScannerConnection.scanFile(<br>                                        <em>context</em>,<br>                                        <em>arrayOf</em>(savedUri.toString()),<br>                                        <em>arrayOf</em>(mimeType)<br>                                ) <strong>{ </strong>_, uri <strong>-&gt;<br>                                    </strong>Log.d(Constants.<strong>TAG</strong>, <strong>&quot;Image capture scanned into media store: $</strong>uri<strong>&quot;</strong>)<br>                                <strong>}<br>                            </strong>}<br>                        })<br>                <em>// We can only change the foreground Drawable using API level 23+ API<br>                </em><strong>if </strong>(Build.VERSION.<em>SDK_INT </em>&gt;= Build.VERSION_CODES.<em>M</em>) {<br>                    <strong>mContainer</strong>.postDelayed(<strong>{<br>                        mContainer</strong>.<em>foreground </em>= ColorDrawable(Color.<em>WHITE</em>)<br>                        <strong>mContainer</strong>.postDelayed(<strong>{ mContainer</strong>.<em>foreground </em>= <strong>null }</strong>, <em>ANIMATION_FAST_MILLIS</em>)<br>                    <strong>}</strong>,<br>                            <em>ANIMATION_SLOW_MILLIS<br>                    </em>)<br>                }<br>            <strong>}<br>        }<br><br>        </strong>camera_switch_button.setOnClickListener <strong>{<br>            mDefaultLen </strong>= <strong>if </strong>(CameraSelector.<em>LENS_FACING_FRONT </em>== <strong>mDefaultLen</strong>) {<br>                CameraSelector.<em>LENS_FACING_BACK<br>            </em>} <strong>else </strong>{<br>                CameraSelector.<em>LENS_FACING_FRONT<br>            </em>}<br>            bindCameraUseCases()<br>        <strong>}<br><br>        </strong>photo_view_button.setOnClickListener <strong>{<br>            if </strong>(<strong>true </strong>== <strong>mOutputDirectory</strong>.listFiles()?.<em>isNotEmpty</em>()) {<br>                Navigation.findNavController(<br>                        requireActivity(), R.id.<em>fragment_container<br>                </em>).navigate(CameraFragmentDirections<br>                        .actionCameraToGallery(<strong>mOutputDirectory</strong>.<em>absolutePath</em>))<br>            }<br>        <strong>}<br>    </strong>}<br><br><br>    <strong>private class </strong>LuminosityAnalyzer(listener: LumaListener? = <strong>null</strong>) : ImageAnalysis.Analyzer {<br>        <strong>private val frameRateWindow </strong>= 8<br>        <strong>private val frameTimestamps </strong>= ArrayDeque&lt;Long&gt;(5)<br>        <strong>private val listeners </strong>= ArrayList&lt;LumaListener&gt;().<em>apply </em><strong>{ </strong>listener?.<em>let </em><strong>{ </strong>add(<strong>it</strong>) <strong>} }<br>        private var lastAnalyzedTimestamp </strong>= 0L<br>        <strong>var framesPerSecond</strong>: Double = -1.0<br>            <strong>private set<br><br>        </strong><em>/**<br>         * Used to add listeners that will be called with each luma computed<br>         */<br>        </em><strong>fun </strong>onFrameAnalyzed(listener: LumaListener) = <strong>listeners</strong>.add(listener)<br><br>        <em>/**<br>         * Helper extension function used to extract a byte array from an image plane buffer<br>         */<br>        </em><strong>private fun </strong>ByteBuffer.toByteArray(): ByteArray {<br>            rewind()    <em>// Rewind the buffer to zero<br>            </em><strong>val </strong>data = ByteArray(remaining())<br>            get(data)   <em>// Copy the buffer into a byte array<br>            </em><strong>return </strong>data <em>// Return the byte array<br>        </em>}<br><br>        <strong>override fun </strong>analyze(image: ImageProxy) {<br>            <em>// If there are no listeners attached, we don&#39;t need to perform analysis<br>            </em><strong>if </strong>(<strong>listeners</strong>.isEmpty()) {<br>                image.close()<br>                <strong>return<br>            </strong>}<br><br>            <em>// Keep track of frames analyzed<br>            </em><strong>val </strong>currentTime = System.currentTimeMillis()<br>            <strong>frameTimestamps</strong>.push(currentTime)<br>            <em>// Compute the FPS using a moving average<br>            </em><strong>while </strong>(<strong>frameTimestamps</strong>.<strong>size </strong>&gt;= <strong>frameRateWindow</strong>) <strong>frameTimestamps</strong>.removeLast()<br>            <strong>val </strong>timestampFirst = <strong>frameTimestamps</strong>.peekFirst() ?: currentTime<br>            <strong>val </strong>timestampLast = <strong>frameTimestamps</strong>.peekLast() ?: currentTime<br>            <strong>framesPerSecond </strong>= 1.0 / ((timestampFirst - timestampLast) /<br>                    <strong>frameTimestamps</strong>.<strong>size</strong>.<em>coerceAtLeast</em>(1).toDouble()) * 1000.0<br>            <em>// Analysis could take an arbitrarily long amount of time<br>            // Since we are running in a different thread, it won&#39;t stall other use cases<br>            </em><strong>lastAnalyzedTimestamp </strong>= <strong>frameTimestamps</strong>.<em>first<br>            // Since format in ImageAnalysis is YUV, image.planes[0] contains the luminance plane<br>            </em><strong>val </strong>buffer = image.<em>planes</em>[0].<em>buffer<br>            // Extract image data from callback object<br>            </em><strong>val </strong>data = buffer.<em>toByteArray</em>()<br>            <em>// Convert the data into an array of pixel values ranging 0-255<br>            </em><strong>val </strong>pixels = data.<em>map </em><strong>{ it</strong>.toInt() and 0xFF <strong>}<br>            </strong><em>// Compute average luminance for the image<br>            </em><strong>val </strong>luma = pixels.<em>average</em>()<br>            <em>// Call all listeners with new value<br>            </em><strong>listeners</strong>.<em>forEach </em><strong>{ it</strong>(luma) <strong>}<br>            </strong>image.close()<br>        }<br>    }<br>}</pre><p>Download the sample project, and used the camera package as Utility in an application for development.</p><p>Link:</p><p><a href="https://github.com/Gurwinder2k16/marsplay.git">Gurwinder2k16/marsplay</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63da87e9efcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Annotations]]></title>
            <link>https://medium.com/@gurwindersingh_37022/android-annotations-30b4a2850d0?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/30b4a2850d0</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[annotations]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 17:46:59 GMT</pubDate>
            <atom:updated>2020-03-03T17:46:59.287Z</atom:updated>
            <content:encoded><![CDATA[<p>Android annotations help the developer to inspect code easily.</p><p>Using android annotations tools such as link help to find a problem and make code easy or improve code quality.</p><p>Important and basic useful annotations.</p><ol><li><strong>@Nullable and @NonNull</strong></li></ol><blockquote><strong>@Nullable -</strong>for accepting null value or make an object optional in some cases.</blockquote><blockquote><strong>@NonNull -</strong>for restricting use to assign null value.</blockquote><p><strong>2. @</strong><a href="https://developer.android.com/reference/androidx/annotation/UiThread"><strong>UiThread</strong></a></p><p>For performing an action in Application Ui Thread and update view’s.</p><blockquote>public abstract @interface UiThread<br>implements Annotation</blockquote><p><strong>3 </strong><a href="https://medium.com/u/2747849280b1"><strong>@</strong></a><strong>AnyThread</strong></p><p>For thread-safe calls to deliver a resultant block. The main purpose of this method is to indicate that you believe a method can be called from any thread; static tools can then check that nothing you call from within this method or class has more strict threading requirements.</p><blockquote>@AnyThread<br>public void deliverResult(D data) { ... }</blockquote><h3>Value constraint annotations</h3><p>Use the <a href="https://developer.android.com/reference/androidx/annotation/IntRange">@IntRange</a>, <a href="https://developer.android.com/reference/androidx/annotation/FloatRange">@FloatRange</a>, and <a href="https://developer.android.com/reference/androidx/annotation/Size">@Size</a> annotations to validate the values of passed parameters. Both @IntRange and @FloatRange are most useful when applied to parameters for which users are likely to get the range wrong.</p><p>The @IntRange annotation validates that an integer or long parameter value is within a specified range. The following example ensures that the alpha parameter contains an integer value from 0 to 255:</p><pre>fun setAlpha(@IntRange(from = 0, to = 255) alpha: Int) { ... }</pre><pre>fun setAlpha(@FloatRange(from = 0.0, to = 1.0) alpha: Float) {...}</pre><pre>fun getLocation(button: View, @Size(min=1) location: IntArray) {<br>    button.getLocationOnScreen(location)<br>}</pre><p>Thanks for reading.</p><p>Enjoy!!.</p><p>Please clap &amp; share and follow the blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30b4a2850d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dagger Dependency Injection]]></title>
            <link>https://medium.com/@gurwindersingh_37022/dagger-dependency-injection-e7b201ca660b?source=rss-ec45a16dae9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7b201ca660b</guid>
            <category><![CDATA[dagger-2]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[dagger-android]]></category>
            <dc:creator><![CDATA[Gurwinder Singh]]></dc:creator>
            <pubDate>Tue, 18 Feb 2020 00:31:14 GMT</pubDate>
            <atom:updated>2020-02-18T00:31:14.456Z</atom:updated>
            <content:encoded><![CDATA[<p>A fast dependency injector for Android and Java.</p><h3>What is Dagger?</h3><p>Dagger is compile time dependency injection in both java and android.Dagger aims to address many of the development and performance issues that have plagued reflection-based solutions.</p><p><strong>Implementation of Dagger</strong></p><p>Four major component for implementation</p><blockquote>Inject — Annotation for Injection module</blockquote><blockquote>Provider — Provide Source of Injection</blockquote><blockquote>Module — Module of Source</blockquote><blockquote>App component — Register &amp; Binding in Application Level.</blockquote><h3><strong>Let’s take deep dive in MVVM Using Dagger</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Impx43VBXdq_uyFIbappA.jpeg" /></figure><h3>Programming Example</h3><p>Implementation MVVM Architecture to inject View model factory using dagger dependency injection framework to resolve boiler plate issues.</p><h3><strong>App Component</strong></h3><pre>@Component(<br>    modules = [<br>        InjectionModules::<strong>class</strong>,<br>        ActivityModule::<strong>class</strong>,<br>        FragmentModule::<strong>class</strong>,<br>        AndroidSupportInjectionModule::<strong>class<br>    </strong>]<br>)<br>@Singleton<br><strong>interface </strong>ViewModelComponent {<br><em><br>    </em>@Component.Builder<br>    <strong>interface </strong>Builder {<br>        @BindsInstance<br>        <strong>fun </strong>application(application: &lt;Application&gt;): Builder<br><br>        <strong>fun </strong>build(): ViewModelComponent<br>    }<br><br><em><br>    </em><strong>fun </strong>inject(appController: ApplicationShared)<br>}</pre><h3><strong>Module</strong></h3><pre>@Module<br><strong>internal abstract class </strong>InjectionModules {<br><br>    @Binds<br>    <strong>internal abstract fun </strong>bindViewModelFactory(factory: &lt;ViewModelFactory&gt;): ViewModelProvider.Factory<br><em><br>    </em>@Binds<br>    @IntoMap<br>    @ViewModelKey(&lt;ViewModel&gt;::<strong>class</strong>)<br>    <strong>protected abstract fun </strong>bindMainViewModel(moviesListViewModel: MainViewModel): &lt;ViewModel&gt;</pre><pre>}</pre><h3><strong>Inject</strong></h3><pre>@Singleton<br><strong>class </strong>ViewModelFactory @Inject<br><strong>constructor</strong>(<strong>private val viewModels</strong>: MutableMap&lt;Class&lt;<strong>out </strong>ViewModel&gt;, Provider&lt;ViewModel&gt;&gt;) :<br>    ViewModelProvider.Factory {<br><br>    <strong>override fun </strong>&lt;T : ViewModel&gt; create(modelClass: Class&lt;T&gt;): T {<br>        <strong>val </strong>creator = <strong>viewModels</strong>[modelClass]<br>            ?: <strong>viewModels</strong>.<em>asIterable</em>().<em>firstOrNull </em><strong>{ </strong>modelClass.isAssignableFrom(<strong>it</strong>.<strong>key</strong>) <strong>}</strong>?.<strong>value<br>            </strong>?: <strong>throw </strong>IllegalArgumentException(<strong>&quot;unknown model class $</strong>modelClass<strong>&quot;</strong>)<br>        <strong>return try </strong>{<br>            creator.get() <strong>as </strong>T<br>        } <strong>catch </strong>(e: Exception) {<br>            <strong>throw </strong>RuntimeException(e)<br>        }<br>    }<br>}</pre><blockquote>@Inject<br><strong>internal lateinit var mViewModelFactory</strong>: ViewModelProvider.Factory</blockquote><h3>Provider / ContributesAndroidInjector</h3><blockquote>@Module<br><strong>abstract class </strong>ActivityModule {<br><br> @ContributesAndroidInjector()<br> <strong>abstract fun </strong>contributeMainActivity(): &lt;&gt;<br>}</blockquote><p>Above example for simple inject view model using dependency injection.</p><p>For more example follow my blogs and comment your thoughts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7b201ca660b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>