Intentservice Prevents Activity From Destroying
Solution 1:
Run it through the debugger with breakpoints in your code and check the id of "this" in the ResultReceiver. It's keeping a local copy of "this" which points to your previous activity, where int mTestVar == 1. The current active Activity is a whole different object, with it's own copy of mTestVar == 2. This is a memory leak.
To answer your question more concisely: Android "destroyed" you activity, but you kept a reference to the Activity in your callback preventing it from being garbage collected. If you want something to "live" across multiple activities you should use a service to store that state (keep in mind a service is NOT a separate thread and should not be used like one).
A side note: When checking variables and general purpose logging it's best to use Log.v/e/i etc. You can filter them at the command line with adb logcat mytag:V *:S or use the logcat built into eclipse.
Post a Comment for "Intentservice Prevents Activity From Destroying"