jannis
08/18/2022, 9:03 AMActivity#addOnNewIntentListener()
within Compose. It works fine in general. However it's registered too later after a process death occurred. Code in 🧵override fun onCreate(savedInstanceState: Bundle?) {
setContent {
addOnNewIntentListener {
...
}
}
}
I want to process shared text. Problem: onNewIntent()
from the Activity is called before the lambda of setContent
is invoked after a process death occured and the user re-starts the app with sharing a text.
• When the App is not restored this works fine because the data is in the normal App intent
• When the App is running already this works because the intent listener is called normallyAlex Vanyo
08/19/2022, 4:12 AMsetContent
. Even when something like addOnNewIntentListener
is directly in the Composable scope (you'd usually want to use something like a DisposableEffect
for adding or removing a listener), that can be too late as you've discovered.
A similar thing would apply for anything along the lines of "call this before onCreate
returns." Everything inside setContent
will be called at some later point in time, as determined by Compose internals.