'Know when an Android app is moved to recent list
I would like to know if there's a way to know when an app goes from foreground to recent app list.
I need this because I want to save all the stuff before the user can swipe it away and kill it brutally
Solution 1:[1]
Consider any type of data into two categories
- Atomic
- Semi-atomic
First one being obvious, you only save it with consent of user.
Example -> payment-transfer, sending-text etc
Second is something little subjective, as you would like to save it as temporary information like half written message which user didn't send which you can save temporarily ( given if user uninstalls the app this data won't be coming back -- but consider this with grain of salt as nobody will stop you from saving it remotely in cloud)
for android OnPause() callback is a good place to save, However if you are working with some drawing app, let a Handler() trigger a save every few seconds.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pankaj Nimgade |
