Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Infinite loop when don't keep activities is enabled #5

Closed
fleficher opened this issue Jun 26, 2019 · 5 comments
Closed

Infinite loop when don't keep activities is enabled #5

fleficher opened this issue Jun 26, 2019 · 5 comments

Comments

@fleficher
Copy link
Contributor

Hi 馃憢

The library doesn't work when the "don't keep activities" is checked in the developer options.
When we start the activity with startForResult (using kotlin coroutines in my case), the desired activity start. But when the user leaves the activity, the activity restarts infinitely and the user needs to kill the app.

Steps to reproduce

You can reproduce this with the sample project.

1- Enable "don't keep activities" in developer options
2- start an activity with startForResult, with a camera intent for example.
3- press back button to leave
4- the camera activity restart again and the user can't go back to the app.

@PhilippeBoisney
Copy link

I confirm.

@fleficher fleficher changed the title Infinite loop when don't keep activities is checked Infinite loop when don't keep activities is enabled Jun 26, 2019
@whalemare
Copy link

whalemare commented Sep 2, 2019

Still reproduced on implementation 'com.github.florent37:inline-activity-result:1.0.2

@victor-denisenko
Copy link
Contributor

victor-denisenko commented Dec 10, 2019

Hi

With option "don't keep activities" activity that call InlineActivityResult#startForResult() dies and ActivityResultFragment lose "listener" field value.

I think we cannot implement same behavior as default Activity#startActivityForResult(). Because, in that way, we must store ActivityResultFragment.ActivityResultListener interface througth death and recreation of process that cause memory leak (because listener stores link to context and cannot be saved in Bundle).

I didnt find way how to bount new activity with new ActivityResultFragment#onActivityResult() result. I looked at some other libraries, but they didnt solve this problem too.

But infinite loop can be fixed (i work on it).

@sevar83
Copy link

sevar83 commented Jan 23, 2020

@victor-denisenko In theory the ViewModel of the caller should survive activity destruction (not process death) so if it is implementing ActivityResultListener and not its fragment/activity then the listener will survive too.
In case of a process death there won't be any memory leak because normally the entire app will be restarted. So preserving an arbitrary callback across process death is impossible.

@florent37
Copy link
Owner

google just fixed that : https://developer.android.com/training/basics/intents/result

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants