Android Activity's getIntent() API documentation isn't clear if application developers should book keep and save the intent at appropriate times for reuse. Fortunately, this doesn't need any explicit action by application developers in onSaveInstanceState().
It is supposed to work for cases when the activity is paused and the process is killed by the framework and later restarted when user resumes the application. The reason this works despite a process kill is because the launch intent is book kept in the framework by Activity manager service. So as long as the framework is alive, its always possible to get back to the launch intent and this is yet another reason as to why its not a good idea to store huge data set as Intent extras, which would end up increasing framework's memory usage.
However, there is another API to update the launch intent via setIntent(). This is needed for cases when a single instance activity is launched via onNewIntent(). Developers often tend to update the launch intent via setIntent(). The only problem is that this new intent is book kept only in the application process space and not in the framework process. Hence, should the application process be killed due to low memory and restarted later on, getIntent() would actually return the first launch intent rather than latest launch intent.
The only workaround at this point is for application developers to save and restore this in onSaveInstanceState() and onRestoreInstanceState() respectively.
It is supposed to work for cases when the activity is paused and the process is killed by the framework and later restarted when user resumes the application. The reason this works despite a process kill is because the launch intent is book kept in the framework by Activity manager service. So as long as the framework is alive, its always possible to get back to the launch intent and this is yet another reason as to why its not a good idea to store huge data set as Intent extras, which would end up increasing framework's memory usage.
However, there is another API to update the launch intent via setIntent(). This is needed for cases when a single instance activity is launched via onNewIntent(). Developers often tend to update the launch intent via setIntent(). The only problem is that this new intent is book kept only in the application process space and not in the framework process. Hence, should the application process be killed due to low memory and restarted later on, getIntent() would actually return the first launch intent rather than latest launch intent.
The only workaround at this point is for application developers to save and restore this in onSaveInstanceState() and onRestoreInstanceState() respectively.
No comments:
Post a Comment