android-architecture-navigation

Passing argument(s) to a nested Navigation architecture component graph

吃可爱长大的小学妹 提交于 2019-11-29 18:28:38
问题 How does one pass argument(s) to a nested Navigation architecture component graph? Let's say I construct my navigation graph to navigate from FragmentA --> Nested , where Nested contains FragmentB --> FragmentC ... If this was a pure FragmentA --> FragmentB... graph, I would just set up the navigation with FragmentADirections.actionFragmentAToFragmentB(argument = foo) . But that action takes zero arguments as soon as you turn B --> C into Nested ... So what am I supposed to do? 回答1: Global

navigation component popUpTo bug

泄露秘密 提交于 2019-11-29 17:02:54
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). Why is that, is it some sort of bug? <fragment android:id="@+id/collection_fragment"> <action android

(Android Studio 3.2 Beta) - Navigation Architecture Component Configuration

若如初见. 提交于 2019-11-29 14:18:13
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 File . Am I missing any steps in the installation? Expected Result: My Situation: My build.gradle

Navigation Architecture Component - New Resource dialog doesn't have Navigation resource type for navigation graph

最后都变了- 提交于 2019-11-29 11:02:52
问题 New Resource dialog doesn't have Navigation resource type for navigation graph even after adding Navigation Architecture Component dependencies def nav_version = '1.0.0-alpha01' implementation "android.arch.navigation:navigation-fragment:$nav_version" implementation "android.arch.navigation:navigation-ui:$nav_version" 回答1: Make sure that you checked the box Settings -> Experimental -> Enable Navigation Editor . The Navigation Editor is an experimental feature, so you must first enable it by

Navigation Architecture Component - Splash screen

牧云@^-^@ 提交于 2019-11-29 07:24:16
问题 I would like to know how to implement splash screen using Navigation Architecture Component. Till now I have something like this A user has to setup his profile in ProfileFragment for the first time and can edit their profile from ChatFragment . My problem is I don't know how to remove SplashFragment from stack after navigation. I've seen conditional navigation but didn't quite understand. 回答1: There is a common misuse of the splash screen when it is shown to the user for some amount of

Navigation Architecture Component- Passing argument data to the startDestination

怎甘沉沦 提交于 2019-11-29 05:26:35
I have an activity A that start activity B passing to it some intent data. Activity B host a navigation graph from the new Navigation Architecture Component.I want to pass that intent data to the startDestination fragment as argument how to do that? TLDR: You have to manually inflate the graph, add the keys/values to the defaultArgs, and set the graph on the navController . Step 1 The documentation tells you to set the graph in the <fragment> tag in your Activity 's layout. Something like: <fragment android:id="@+id/navFragment" android:name="androidx.navigation.fragment.NavHostFragment" app

java.lang.IllegalArgumentException: navigation destination xxx is unknown to this NavController

我与影子孤独终老i 提交于 2019-11-28 20:06:19
I am having issue with the new Android Navigation Architecture component when I try to navigate from one Fragment to another , I get this weird error: java.lang.IllegalArgumentException: navigation destination XXX is unknown to this NavController Every other navigation works fine except this particular one. I use: findNavContoller() extension function of Fragment to get access to the navControler. Any help will be appreciated. In my case, if the user clicks the same view twice very very quickly, this crash will occur. So you need to implement some sort of logic to prevent multiple quick clicks

Navigation Architecture Component - Login screen

坚强是说给别人听的谎言 提交于 2019-11-28 11:39:12
I am planning to implement navigation like this: The problem I face is when user is in LoginFragmennt and presses back button it again loads up LognFragment ie. stuck in loop. I navigate to LoginnFragment using conditional navigation as per this answer. How to properly implement this? One of the solutions that i can propose is to override inside your activity onBackPressed method, and finish the activity if your current destination(before on back pressed handled) is login fragment. override fun onBackPressed() { val currentDestination=NavHostFragment.findNavController(nav_host_fragment)

navigation component popUpTo bug

这一生的挚爱 提交于 2019-11-28 10:33:16
问题 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)

Is it possible to set startDestination conditionally using Android Navigation Architecture Component(Android Jetpack)?

六眼飞鱼酱① 提交于 2019-11-28 08:13:57
I am using Navigation from Android Jetpack to navigate between screens. Now I want to set startDestination dynamically. I have an Activity named MainActivity And two Fragments, FragmentA & FragmentB. var isAllSetUp : Boolean = // It is dynamic and I’m getting this from Preferences. If(isAllSetUp) { // show FragmentA } else { //show FragmentB } I want to set above flow using Navigation Architecture Component. Currently I have used startDestionation as below but it’s not fulfilling my requirement. <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas