GitHub user breautek added a comment to the discussion: Cordova with registerForActivityResult.
the androidx's `registerForActivityResult` must be called before the activity is created. I believe it is valid to register activity result callbacks during the `onCreate` lifecycle event as that's something I've done [here](https://github.com/breautek/cordova-imagePicker/blob/android-11-support/src/android/Library/src/MultiImageChooserActivity.java#L154). > Note: You must call registerForActivityResult() before the fragment or > activity is created, but you can't launch the ActivityResultLauncher until > the fragment or activity's > [Lifecycle](https://developer.android.com/reference/androidx/lifecycle/Lifecycle) > has reached > [CREATED](https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#CREATED). https://developer.android.com/training/basics/intents/result#register I'm not aware of any cordova plugins that actually makes use of the androidx's APIs, most plugins will hook into the older API, including the cordova framework itself, which exposes the original activity result APIs. But I can provide some information that might assist you. Cordova plugins are lazy-loaded by default. This means they are not created/initialised until they are called upon by the javascript. This will be well-after the onCreate lifecycle event and if you're plugin initialises at this time, it will be too late to register activity result callbacks. This is undocumented, and potentially an implementation detail, so it might be dangerous to rely on this... but if the plugin is marked to initialize [onload](https://cordova.apache.org/docs/en/12.x/guide/platforms/android/plugin.html#plugin-initialization-and-lifetime), then the plugin will be initialised when Cordova is initialised on load, which happens to be during the `onCreate` lifecycle event. Therefore if the plugin has `onload` enabled, and it registers the activity result callback in it's `initialize` method, then it should work. GitHub link: https://github.com/apache/cordova/discussions/485#discussioncomment-9986780 ---- This is an automatically sent email for issues@cordova.apache.org. To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org