Test application by deleting activity

cutstone

Member
Licensed User
Longtime User
When an activity moves to background, Android OS may or may not delete the activity. In order to test if my application works correctly in every case, can I force Android to delete activities in backgrounds?
 

cutstone

Member
Licensed User
Longtime User
Thank you for this tip. Using a task manager helps me to debug this temporary error people some time report abount my application.
This setting you refer to under Developer, that automatically kill background task... Could it have been introduced in a newer Android version, because I cannot find it in 2.3.5?
 
Upvote 0

cutstone

Member
Licensed User
Longtime User
I have used a task manager to test if my application was robust to Androids life cycle. It turns out that the task manager killed not only kills the activities in background, but also the process and it variables, according to the discussion on http://www.b4x.com/forum/basic4andr...ect-disappear-process_globals.html#post115426

The Task Manager I used was (first I found on play) “Advanced Task Killer”. Do you know of a task manager, which only deletes the background activities?

I still haven’t succeeded finding the open under Settings – Developer you mentioned above.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
I'm not so sure you can kill a specific activity that is cached in the background unless it is something that is in a newer OS as you said.

After using B4A for over a year now, I've fixed plenty of problems that came up when my app was cached in the background and it was force-closed either by the user, a task killer or the OS. I've been able to diagnose and fix all of them by simply force-closing my app in the phone's built-in task manager in order to test things.

I would agree that seeing what happens to your app when this happens is a very important part of writing a reliable Android app. It can be a huge source of Null Pointer Exception errors.

One way I found to somewhat reliably have my app's other background activities get killed by the OS was to press Home while on one of my activities and then use the heck out of the phone by running memory-intensive apps such as large games, browsing websites and watching videos, etc. I used this method to track down a NPE problem a few times.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
On Android 4.0 devices (or emulator) you can check Don't keep activities:

SS-2012-07-30_10.29.42.png
 
Upvote 0

cutstone

Member
Licensed User
Longtime User
Thanks Kevin for your comments. Happy to know I’m not the only one considering this problem. Using memory intensive might kill your activities, but you are never really sure.

I guess Erels advice to use Android 4.0 or emulator with developer option, is the only safe method to make sure an application is tested correctly for Android Life Cycle. Thank you both for answers that put me on the right track.
 
Upvote 0
Top