<?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 Prabhat Singh on Medium]]></title>
        <description><![CDATA[Stories by Prabhat Singh on Medium]]></description>
        <link>https://medium.com/@prabhatsingh_91106?source=rss-b052ba20e358------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*veC6JNtduOiC4IrP.</url>
            <title>Stories by Prabhat Singh on Medium</title>
            <link>https://medium.com/@prabhatsingh_91106?source=rss-b052ba20e358------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 23:27:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prabhatsingh_91106/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android Jet Pack : Say “Bye” to The FragmentTransaction and StartActivity]]></title>
            <link>https://medium.com/@prabhatsingh_91106/android-jet-pack-say-bye-to-the-fragmenttransaction-and-startactivity-94c8f7e3ae01?source=rss-b052ba20e358------2</link>
            <guid isPermaLink="false">https://medium.com/p/94c8f7e3ae01</guid>
            <category><![CDATA[android-navigation-graph]]></category>
            <category><![CDATA[android-jet-pack]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-new-navigation]]></category>
            <dc:creator><![CDATA[Prabhat Singh]]></dc:creator>
            <pubDate>Mon, 25 Jun 2018 16:34:50 GMT</pubDate>
            <atom:updated>2018-06-26T23:27:26.458Z</atom:updated>
            <content:encoded><![CDATA[<p>Finally , Google has come up with the new Navigation which is both very easy and fast to implement.This small example will briefly explain the implementation of this new library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83lb6QqgP3dFIDxlOubhFA.png" /><figcaption>Snippet showing the navigation graph</figcaption></figure><p>Let’s understand the implementation step by step:</p><ol><li>First thing first, add the following dependency to your app’s build.gradle</li></ol><pre>implementation &#39;android.arch.navigation:navigation-fragment:1.0.0-alpha01&#39;</pre><p>2. Also please ensure if you are using Android studio 3.2 (right now its in preview version) . <strong>Now the interesting part begins</strong></p><p>3. Right click on the project and select New &gt; Android Resource File</p><p>4. Select “Resource Type” as navigation. Name this xml “<strong>nav_graph</strong>”. (You can name it anything you like)</p><p>5. Open the “<strong>nav_graph.xml</strong>” file. Toggle to design window. On the top left you will see an icon with “+” over it. Use it to create the Fragments.</p><p>6. As per snippet above drag an arrow from the source fragment ( Fragment which is going to launch another fragment) to the destination fragment (the fragment which is going to be launched).</p><p>7. Now your nav_graph.xml will look like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j69djTT1jUc3kp3LDP4sMA.png" /><figcaption>nav_graph.xml</figcaption></figure><p>8. Now in <strong>Fragment1.kt</strong>. Handle the click of buttons as below (Code is in kotlin. You can use JAVA as well)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R2Y4aFNSm6WiPdBsyci6sg.png" /><figcaption>Handling button clicks</figcaption></figure><p>9. We are using the action id’s to navigate.</p><p>10. Finally in your activity’s xml you need to add <strong>NavHostFragment. Should look like below:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UrR8rypheyOiV7s2vm1Ukw.png" /></figure><p>11. The app:defaultNavHost=&quot;true&quot; attribute. This attribute ensures your NavHostFragment intercepts the system Back button. You will also overwrite <a href="https://developer.android.com/reference/android/support/v7/app/AppCompatActivity">AppCompatActivity.onSupportNavigateUp()</a> and call <a href="https://developer.android.com/reference/androidx/navigation/NavController.html#navigateUp()">NavController.navigateUp</a> as follows:</p><pre>override fun onSupportNavigateUp()<br>        = findNavController(R.id.nav_host_fragment).navigateUp()</pre><p>That’s all…..</p><p>Thank you….. :-)</p><h4>More where this came from</h4><p>This story is published in <a href="http://blog.usejournal.com/">Noteworthy</a>, where thousands come every day to learn about the people &amp; ideas shaping the products we love.</p><p>Follow our publication to see more product &amp; design stories featured by the <a href="https://usejournal.com/?utm_source=usejournal.com&amp;utm_medium=blog&amp;utm_campaign=guest_post">Journal</a> team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94c8f7e3ae01" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>