Open BoxResin opened 3 years ago
This feature may fix the issue.
This documentation also maybe helpful.
Hello.
This documentation also maybe helpful.
If you want to use the new Activity Result API, then you don't need this library, IMO.
This feature may fix the issue.
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).
@victor-denisenko Thanks for your opinions.
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.
https://user-images.githubusercontent.com/13031505/104625606-42e28c00-56d8-11eb-9213-39f8401cbd84.mp4