Properly detect when the app goes to the background - #4036
Merged
Conversation
Contributor
|
@daniloercoli I've been testing this for some time now with Code looks good, but can you add some comments on top of |
Contributor
Author
|
@maxme - Added comments that describe our onBackground detection |
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4033 by adding a Timer and a TimerTask that handles all the
onBackgroundcode. [Details below].As explained in the ticket the current implementation doesn't detect when the app goes to background in case of device running in "low memory" condition.
I've tried different solutions, but this one was the most reliable to me.
The proposed solution use the methods
onActivityPausedandonActivityResumedofApplicationLifecycleMonitorto start and stop the timer that detects when the app goes to background.So in the case when the user is simply navigating between the activities, the
onActivityPaused()starts the timer, but almost immediately the new activity being entered, the ApplicationLifecycleMonitor cancels the timer in itsonActivityResumedmethod. And somIsInBackgroundwould be false.In the case the app is sent to background, the TimerTask is executed and the code that handles all the background logic is run.
Please, double check that everything is working fine with Dialogs and Prompts.