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 Feb 8, 2022. It is now read-only.
I found a trivial bug. rx and coroutine packages are affected by this.
Scenario
A Activity starts B Activity.
Rotate the screen in B Activity.
Tap the back button in B Activity.
A Activity will lost the activity result from B Activity.
Activitys are recreated when the screen rotates as we know. Starting another Activity is also the case. If B Activity has been rotated, then A Activity get recreated.(It's deferred until B Activity is finished) In this case, A Activity calling startActivityForResult() never get callback for onActivityResult(). (It would be called in another instance of A Activity).
I attach a video that actually reproduces the bug.
device-2021-01-15-021348.mp4
The text was updated successfully, but these errors were encountered:
BoxResin
changed the title
No preparation for Activity recreation when the screen rotates
No countermeasure for Activity recreation when the screen rotates
Mar 3, 2021
Yes, shared ViewModel can store com.github.florent37.inlineactivityresult.Result value.
But we need to store com.github.florent37.inlineactivityresult.InlineActivityResult callbacks also and in this case it will cause memory leak. We can use LiveData observer to get a result in activity/fragment, but it breaks RX chain logic (RX subscriber will be unused).
In simple words, the library needs to store some internal callbacks and with screen rotation it must be to resubscribed to a new observer (activity/fragment). ViewModel won't help (without huge rewriting of implementation). The new Activity Result API solve this problem in the other way using some private methods in activity. I don't found RX wrapper for Activity Result API lib (but its necessary? probably no).
I found a trivial bug.
rx
andcoroutine
packages are affected by this.Scenario
Activity
starts BActivity
.Activity
.Activity
.Activity
will lost the activity result from BActivity
.Activity
s are recreated when the screen rotates as we know. Starting anotherActivity
is also the case. If BActivity
has been rotated, then AActivity
get recreated.(It's deferred until BActivity
is finished) In this case, AActivity
callingstartActivityForResult()
never get callback foronActivityResult()
. (It would be called in another instance of AActivity
).I attach a video that actually reproduces the bug.
device-2021-01-15-021348.mp4
The text was updated successfully, but these errors were encountered: