Reputation: 4686
In the flow diagram for an Android app activity lifecycle (shown below) there is a route by which the 'App process' is killed and onDestroy()
is not called. It seems this is most commonly done to free up memory resources for a different activity.
All that is fine, but how do I test this scenario? Either on device or in the simulator.
Upvotes: 4
Views: 1741
Reputation: 13009
If you force stop your app, all BroadcastReceivers and also app widgets, which extend BroadcastReceiver, will stop working. See also this SO post by Commonsware
So force stopping the app is not ideal for testing app behavior under low memory conditions. What else can you do?
This is the same as the kernel killing those processes to reclaim memory
Upvotes: 2
Reputation: 4702
Steps:
Important note: DO NOT use back button when leaving your app when you are going to system settings, use home button instead so the app does not get killed.
Upvotes: 0
Reputation: 57672
The easiest and most clean solution to test those life cycle is to enable the "Don't Keep Activities" settings in the developer settings on your device.
This way you even get your activity killed as soon as you start a new activity. So if you press back than the old activity will be recreated.
Upvotes: -1