julioromano
03/02/2021, 10:18 AMNavController
from Activity.onNewIntent()
?julioromano
03/02/2021, 10:19 AMNavController
within onNewIntent()
which is outside of the composition.
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
navController.handleDeepLink(intent)
}
For instance: I’ve tried grabbing a ref to NavController
as a side effect with .apply
like:
setContent {
val navController = rememberNavController().apply {
navController = this // navController is a global instance var
But I end up getting crashes at runtime because that global var is not initialized yet when onNewIntent()
is called.allan.conda
03/02/2021, 10:25 AMprivate var intent : Intent? by mutableStateOf(null)
fun onNewIntent(newIntent) {
intent = newIntent
}
setContent {
val navControler = ...
SideEffect(Intent) {
navController...
}
}
allan.conda
03/02/2021, 10:27 AMIan Lake
03/02/2021, 3:02 PMlaunchMode
at all. NavController will handle deep links for you thenallan.conda
03/02/2021, 3:03 PMjulioromano
03/02/2021, 4:42 PMlaunchMode="singleTask"
still seems a legit use case for single activity apps. It wouldn’t make sense for those apps to have multiple instances of their activity created by the system. What to do in such case?
Docs are currently mentioning this here: https://developer.android.com/reference/kotlin/androidx/navigation/NavController#handledeeplinkIan Lake
03/02/2021, 5:20 PMsingleTask
either. That breaks implicit deep links on other app's tasks (something that Navigation also fully supports)