Code modules do not hold any context of their own. Therefore they cannot handle events or CallSub calls. You should instead use a class or service.
I can get a "Code" module routine to run when called from the class "hard coded". For example it creates a notification in the background.
I've tried the project you attached. I pressed on the Start button and then on the Home button. After 10 seconds the main activity is started.
I guess that you see a different behavior, right?
Make sure that the process is not killed while it is in the background.
You have success with the check box both checked and un-checked? Which device?
I'm quite perplexed. It (Class starting Activity, i.e. checkbox unchecked) doesn't work on a Note2 phone, Lenovo 7" tab or Bluestacks emulator. I changed the Class variable in the activity to be a Global variable vs process_global and here's what happens. The first time it pops the msgbox when I use recent apps key, on the second try it has "Initialized" error so the class instance variable still seems to hold valid data the first time, but not the second time. Other findings:
When calling StartActivity from service the Activity_Create is not re-called, whereas when I bring the app forward again via the recent apps key Activity_Create is called again and FirstTime=False. Note Activity_Create is only called again from recent apps key if the timer tried to start the activity from the class. When the app is in the background without the timer running, launching it via recent apps DOES NOT run Activity_Create again.
In summary, StartActivity from within Service does not call Activity_Create whereas StartActivity from within class does, and only when the app is brought up again via the recent apps, which is kind of odd since the call to the class to start the activity is called from the service.
EDIT: I had the test app running (sitting in background) in the emulator for 12 hours today and when I brought it forward it did not run the Activity_Create event.