Wojciech Rozwadowski
06/20/2024, 2:10 PMonActivityResult
in Compose if startActivityForResult
is triggered by an external SDK and we don't have direct access to it?Wojciech Rozwadowski
06/20/2024, 2:10 PMrememberLauncherForActivityResult
only allows for launching activities and doesn't provide the option to register for result notifications directly.Wojciech Rozwadowski
06/20/2024, 2:13 PMActivityResultRegistry.register()
with LocalActivityResultRegistryOwner.current.activityResultRegistry
, but we cannot do this in Compose due to the application being in the wrong state RESUMED
instead of STARTED
java.lang.IllegalStateException: LifecycleOwner com.app.main.MainActivity@f90bdab is attempting to register while the current state is RESUMED. LifecycleOwners must call register before they are STARTED.
Stylianos Gakis
06/20/2024, 2:19 PMrememberLauncherForActivityResult
looks to call register from a DisposableEffect https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity[…]rActivityResult&ss=androidx%2Fplatform%2Fframeworks%2Fsupport, do you do the same and get this error that you are describing?Ian Lake
06/20/2024, 2:43 PMstartActivityForResult
, the only way to get the result from that is from onActivityResult
up at the activity (or fragment, depending on how the SDK works) layer. The Activity Result APIs will only send you a response if you launch
them - they cannot intercept other activity result requests. You should ask that SDK to provide an Activity Result Contract, which would ensure it could be used in an activity, fragment, or composable