Try ensuring the .launch()
call is distant from the registration call (at least not in the same (re)compose).
I suspect the Photo Picker behaves like other Activities, and thus this note from docs on getting results from activities would apply (emphasis mine):
Note: You must call
registerForActivityResult()
before the fragment or activity is created, but you can't launch theActivityResultLauncher
until the fragment or activity'sLifecycle
has reachedCREATED
.
To me, this implies registerForActivityResult
must be called early enough for the Lifecycle
of the underlying Photo Picker activity to reach CREATED
, though I'm unsure how to test that theory.
I only started Android dev today so 0 experience and YMMV, but this resolved the same issue for me.