我应该创建一个导致MainActivity的Intent,然后在其中导航功能。还是有其他方法?
答案 0 :(得分:0)
从通知中将挂起的意图写入MainActivity,然后使用其ID导航至特定片段
val bundle = intent.extras
findNavController(R.id.homeHostFragment)
.navigate(R.id.notificationsFragment, bundle, null)
或
//here homeHostFragment is the id for fragment in xml for which we set the nav graph
val bundle = intent.extras
val navHostFragment = homeHostFragment as NavHostFragment
navHostFragment.navController.navigate(R.id.notificationsFragment,bundle)