When to destroy activity's presenter
See original GitHub issueWe need a more reliable way to detect when to destroy activity’s presenter.
Here is where the issue that started the discussion: https://github.com/konmik/nucleus/issues/42#issuecomment-204233175
TL/DR: activity’s finish()
can be called some time after onPause
, so this code will leak the activity’s presenter: https://github.com/konmik/nucleus/blob/master/nucleus/src/main/java/nucleus/view/NucleusActivity.java#L76
Possible solutions:
a) Leverage retained fragments. This will solve the presenter destruction issue but we will leak background tasks sometimes.
b) Extend PresenterLifecycleDelegate
lifecycle to explicitly call onDestroy
.
c) Install system-wide lifecycle listener registerActivityLifecycleCallbacks
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:51 (27 by maintainers)
Top Results From Across the Web
MVP: Don't keep activities.Is presenter alive? - Stack Overflow
Yes. When your activity is destroyed, all the objects in that activity will also be destroyed. You can recover the state of some...
Read more >Android MVP: Keeping Presenters Alive | craigrussell
When the View is being destroyed, we inform the Presenter so that it doesn't try to update an invalid View. The rest of...
Read more >The activity lifecycle - Android Developers
When your activity is destroyed because the user presses Back or the activity finishes itself, both the system's and the user's concept of...
Read more >Model-View-Presenter: Android guidelines - Medium
The presenter doesn't make sense without a view. It comes with the view and goes when the view is destroyed. It manages one...
Read more >MVP for Android: how to organize the presentation layer
The presenter is defined as a property for the activity, and when the button is clicked, it calls validateCredentials() , which will notify...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
3.0.0-beta is on maven
Hey, can we use isChangingConfigurations() instead of isFinishing()? So presenter will NOT be destroyed only if it is configuration change incoming.