Navigation graphs and multiple host activities

2019-08-18 08:16发布

问题:

I have a feature module, splash, which has a nav_splash graph and a SplashActivity.

When I navigate to a second feature module, main, which has a nav_main graph and a MainActivity, instead of using MainActivity as host (even in the navigation editor it is appearing as host), it keeps using SplashActivity as host.

So instead of navigating to nav_main graph, now I have to navigate to an activity (MainActivity) to force the use of this activity as host.

Is this intentionally? Or is it a bug?

The first reason to use multiple activities is that they have different themes in the manifest file.

回答1:

Unless you're specifically navigating to an <activity> destination, you'll stay in the same activity, that is working as intended.