You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
Hi, as of AndroidX supports lifecycle and Activity result listening (currently rc 'androidx.activity:activity:1.2.0-rc01') it seemed that this library could be replaced. But so far difference is that lifecycle listeners can be add only before onResume() what requires quite some changes to old code bases, when you want for example catch onActivityResult() from dialog (eg. open android file chooser). And dialog is open from menu, which is created by onCreateOptionsMenu().
Am I missing something or is there possibility do add lifecycle listener after onResume?
Thx for reaction. If you call 'ActivityResultCaller#registerForActivityResult' after 'onResume' android framework throws Exception.
I can see there is obvious reason that it must be done this way to create listeners again if activity was destroyed due to rotation or whatever.
In my particular case I am working on app which is about 9 years old. I am creating options menu in onCreateOptionsMenu so to use Android Lifecycle listening I would have refactor code to use composition of menus ie. this:
Hi, as of AndroidX supports lifecycle and Activity result listening (currently rc 'androidx.activity:activity:1.2.0-rc01') it seemed that this library could be replaced. But so far difference is that lifecycle listeners can be add only before onResume() what requires quite some changes to old code bases, when you want for example catch onActivityResult() from dialog (eg. open android file chooser). And dialog is open from menu, which is created by onCreateOptionsMenu().
Am I missing something or is there possibility do add lifecycle listener after onResume?
ComponentActivity
ActivityResultCaller#registerForActivityResult
The text was updated successfully, but these errors were encountered: