android-architecture-navigation

How to change start destination of a navigation graph programmatically [Jetpack]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-20 02:09:47
问题 Basically, I have the following navigation graph: I want to change my starting point in navigation graph to fragment 2 right after reaching it (in order to prevent going back to fragment 1 when pressing back button - like with the splash screen). This is my code: navGraph = navController.getGraph(); navGraph.setStartDestination(R.id.fragment2); navController.setGraph(navGraph); But, obviously it's not working and it gets back to fragment 1 after pressing back button. Am I doing it wrong? Is

How to set up Navigation Component with Navigation Drawer in Android?

放肆的年华 提交于 2020-01-14 04:41:04
问题 How do I set up navigation component with navigation drawer? How do I use it in my app? Can everything be done with one Activity? How do I handle toolbar visibility with just one Activity and fragments which have a dynamic toolbar visibility. Also, there are fragments which I need to close the drawer and make it inaccessible. This question is a self answered question and works more as a tutorial than a real-life QA. 回答1: How do I set up navigation component with navigation drawer? How do I

Navigation destination unknown to this NavController after an activity result

本小妞迷上赌 提交于 2020-01-12 03:36:07
问题 i'm using nav controller 1.0.0alpha05 and it is working great, but i'm struggling with this dreaded error when i execute a navigation action after an activity result. I have a single activity/multiple fragments structure, in particular a fragment with a list of items and another one with the form for adding a new one. When i add another one without any picture it is working and returning to the previous one with the list of items, but when i take some photos i get the exception during the

Pass data/bundle using navigateUp in Android Navigation Component

狂风中的少年 提交于 2020-01-11 05:15:08
问题 I found the question but does not have solution in code I want to have data when backpress/manual back happens. I am using navigateUp() to go back. How can I pass data to previous fragment? navigateUp() does not have any facility to pass data to previous fragment. Even I did not find solution using Safe Args. It's passing data forward. I want to have in backward Frad B -> Frag A. My code to go back to previous fragment Navigation.findNavController(view).navigateUp() My question is, How can i

Pass data/bundle using navigateUp in Android Navigation Component

拈花ヽ惹草 提交于 2020-01-11 05:15:07
问题 I found the question but does not have solution in code I want to have data when backpress/manual back happens. I am using navigateUp() to go back. How can I pass data to previous fragment? navigateUp() does not have any facility to pass data to previous fragment. Even I did not find solution using Safe Args. It's passing data forward. I want to have in backward Frad B -> Frag A. My code to go back to previous fragment Navigation.findNavController(view).navigateUp() My question is, How can i

How to prevent previous fragment to show up after pressing back button using navigation controller?

馋奶兔 提交于 2019-12-31 01:49:13
问题 I am trying to use the navigation controller right now. I want to move from LoginFragment to HomeFragment . In LoginFragment I use this code below to move to HomeFragment . Navigation.findNavController(view).navigate(homeDestination) However, when I tap the back button in the HomeFragment , it will go back to LoginFragment , I expect that when I tap the button it will close the app. In old way, if I use activity instead of using Fragment , I usually do something like this to get that expected

Android Jetpack Navigation, BottomNavigationView with Youtube or Instagram like proper back navigation (fragment back stack)?

走远了吗. 提交于 2019-12-29 10:07:20
问题 Android Jetpack Navigation, BottomNavigationView with auto fragment back stack on back button click? What I wanted, after choosing multiple tabs one after another by user and user click on back button app must redirect to the last page he/she opened. I achieved the same using Android ViewPager, by saving the currently selected item in an ArrayList. Is there any auto back stack after Android Jetpack Navigation Release? I want to achieve it using navigation graph activity_main.xml <?xml version

(Android Studio 3.2 Beta) - Navigation Architecture Component Configuration

前提是你 提交于 2019-12-29 08:43:05
问题 I want to try out the new Navigation Architecture Component feature, so I followed this Tutorial: https://www.youtube.com/watch?v=GOpeBbfyb6s. I am using Android Studio 3.2 Beta 1. I installed the necessary dependencies, but when I try to create the Navigation Android Resource File in the project just like in the video above, the Navigation option does not appear in the selection menu. My Issue: There is no Navigation option to select while trying to create the Navigation Android Resource

Android JetPack Navigation : How to open a fragment from an activity not associated with it?

岁酱吖の 提交于 2019-12-25 01:06:46
问题 scenario : MainActivity.kt : activity_main.xml contains my_nav_host_fragment in mobile_navigation.xml first_frag_dest is the startDestination and there is second_frag_dest also, with respective classes FirstFragment.kt and SecondFragment.kt . I have setup bottom navigation for switch between two fragments using the Android Jetpack Navigation components. When the Second Fragment is opened for the first time if FirbaseUser is null, A Welcome Activity is launched which is configured for

navigation component popUpTo bug

老子叫甜甜 提交于 2019-12-24 16:23:17
问题 Recently I ran into issue that I asked about here But when trying to figure out what's happening I always stumble on the same problem. Here's what I have - I have a collection, preview, edit fragments than I need to navigate between. But after navigating from edit fragment to preview fragment I want the back button to take user to collection fragment instead of edit fragment, and it does that, but when trying to navigate further it crashes because the destination is said to be (view_fragment)