This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
android:structure_of_an_android_app [2017/06/18 11:20] ko4bb |
android:structure_of_an_android_app [2017/06/18 17:12] ko4bb |
||
---|---|---|---|
Line 23: | Line 23: | ||
This is where it becomes interesting, particularly if you have experience writing software for a desktop operating system like Windows or Linux. | This is where it becomes interesting, particularly if you have experience writing software for a desktop operating system like Windows or Linux. | ||
- | The Android OS is designed to optimize battery and memory usage. Therefore Android can and will stop (and unload from RAM) any process that is not currently active (note that it is easy to keep a Service module active so that it is not unloaded, like a messaging app). You have no control of this, it may happen immediately or after a short delay depending on how busy the device is. | + | The Android OS is designed to optimize battery and memory usage. Therefore Android can and will stop (and unload from RAM) any process that is not currently active (note that a Service module will only be unloaded if the OS has already unloaded paused Activities and still needs more resources). You have no control of this, it may happen immediately or after a short delay depending on how busy the device is. |
The consequence of that is that if you have an app composed of an Activity and you momentarily leave your app to check your mail for instance; even if you do not close the app when you check your mail, the Activity will start anew when you return to it. The OS will not automatically save the state of your app for you. If you want to return where you were in the app, you have to save the state yourself. That sounds like a pain and it is, but it is better than having the OS guess what you want to keep and what not. There are reasons for this. | The consequence of that is that if you have an app composed of an Activity and you momentarily leave your app to check your mail for instance; even if you do not close the app when you check your mail, the Activity will start anew when you return to it. The OS will not automatically save the state of your app for you. If you want to return where you were in the app, you have to save the state yourself. That sounds like a pain and it is, but it is better than having the OS guess what you want to keep and what not. There are reasons for this. |