android-architecture-navigation

Android Navigation Component: Start at a different destination than home, programmatically?

非 Y 不嫁゛ 提交于 2020-08-02 19:00:13
问题 I'm trying to implement a multiple navigation controller with multiple back stack BottomNavigationView , as per the github examples. However, the example uses a different nav graph for each tab, which makes things easy. In my case I need to use the same nav graph for all of my tabs, but with different start destinations, than the "home destination" set in the nav graph. So far I've managed to modify the NavigationExtensions file in order to achieve the single navgraph for all tabs, and I get

Android Navigation Component: Start at a different destination than home, programmatically?

天涯浪子 提交于 2020-08-02 18:59:35
问题 I'm trying to implement a multiple navigation controller with multiple back stack BottomNavigationView , as per the github examples. However, the example uses a different nav graph for each tab, which makes things easy. In my case I need to use the same nav graph for all of my tabs, but with different start destinations, than the "home destination" set in the nav graph. So far I've managed to modify the NavigationExtensions file in order to achieve the single navgraph for all tabs, and I get

Android Navigation Component: Start at a different destination than home, programmatically?

五迷三道 提交于 2020-08-02 18:57:09
问题 I'm trying to implement a multiple navigation controller with multiple back stack BottomNavigationView , as per the github examples. However, the example uses a different nav graph for each tab, which makes things easy. In my case I need to use the same nav graph for all of my tabs, but with different start destinations, than the "home destination" set in the nav graph. So far I've managed to modify the NavigationExtensions file in order to achieve the single navgraph for all tabs, and I get

How to pass arguments to a fragment using bottom navigation view and Android Navigation component?

血红的双手。 提交于 2020-08-02 06:17:48
问题 Is it possible to pass and access arguments in a fragment using a bottom navigation view and the Navigation component? I'm using a one activity with many fragments approach where my top level fragment requires an argument(Usually done via the newInstance generated method). I've had a look at the Navigation component developer guide and the codelab but it only mentions using safeargs and adding argument tags in the destinations and actions. Here's my navigation graph: <navigation xmlns:app=

how to setup different toolbar using navigation controller component?

孤人 提交于 2020-08-01 16:45:59
问题 I am actually not sure, how the correct way or the best practice to set different toolbar using navigation controller component in my app. I want to set 2 different toolbars. green toolbar red toolbar two toolbars with different colour. this is just to simplify the case, actually I have multiple toolbars I am using navigation controller component. and currently on my Main Activity as the host, I set the green toolbar in my main activity using this code setSupportActionBar(green_toolbar)

How to scope a view model to a parent fragment?

╄→гoц情女王★ 提交于 2020-07-30 05:57:08
问题 So I'm using the new navigation component (with the one activity principle) and communicating between each fragment using shared view models, however, I've come to a point where I sometimes need to clear the view model but I can't find a good place to clear it. But tbh I think rather than trying to clear it myself, I should really be allowing the framework to do it for me, but it doesn't because the view models are shared and scoped to the activity, but I think I can scope them to a parent

How to scope a view model to a parent fragment?

旧时模样 提交于 2020-07-30 05:55:00
问题 So I'm using the new navigation component (with the one activity principle) and communicating between each fragment using shared view models, however, I've come to a point where I sometimes need to clear the view model but I can't find a good place to clear it. But tbh I think rather than trying to clear it myself, I should really be allowing the framework to do it for me, but it doesn't because the view models are shared and scoped to the activity, but I think I can scope them to a parent

Android Espresso does not have a NavController set Error

[亡魂溺海] 提交于 2020-07-23 06:52:16
问题 I am trying to test a fragment in my navigation architecture and my test is as follows: test.kt @RunWith(AndroidJUnit4::class) @MediumTest internal class AddingAccountTest{ @get:Rule var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) @Before fun loadCorrespondingFragment(){ } @Test fun checkThatAllFieldsInFormAreEmpty(){ // Create a TestNavHostController val navController = TestNavHostController(ApplicationProvider.getApplicationContext())

Android Espresso does not have a NavController set Error

我是研究僧i 提交于 2020-07-23 06:51:19
问题 I am trying to test a fragment in my navigation architecture and my test is as follows: test.kt @RunWith(AndroidJUnit4::class) @MediumTest internal class AddingAccountTest{ @get:Rule var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) @Before fun loadCorrespondingFragment(){ } @Test fun checkThatAllFieldsInFormAreEmpty(){ // Create a TestNavHostController val navController = TestNavHostController(ApplicationProvider.getApplicationContext())

Android navigation components with deep link: onNewIntent called multiple times

荒凉一梦 提交于 2020-07-22 08:29:44
问题 This time I need your help regarding the use of android navigation components with deeplink. I have been following this documentation and the connection between fragment and deeplink is working fine. The problem comes in regards to the activity that is receiving the deeplink. In my case, I set the android:launchMode="singleTask" <activity android:name=".features.welcome.WelcomeActivity" android:launchMode="singleTask"> <nav-graph android:value="@navigation/welcome_nav_graph" /> </activity>