So I am trying to launch the intent Intent.ACTION_OPEN_DOCUMENT
. I first tried with startActivityForResult
but I noticed it was depreciated so I tried to find another way to do this. So I found the registerForActivityResult
method but it turns out it must run after onCreate() has finished :
Note: While it is safe to call registerForActivityResult() before your fragment or activity is created, you cannot launch the ActivityResultLauncher until the fragment or activity's Lifecycle has reached CREATED.
Since I am using Jetpack Compose and setContent is in onCreate() my Activity has actually never finished creating because all my Composables functions are run in the setContent of my MainActivity
So how can I achieve this ?