This is a design issue and needs to change.
We should revert the change made by
TIMOB-9831 and stop all services when backing out of the app. If an app developer wants a service to keep running when backing out, then they should set up the root window's exitOnClose property to false so that the UI and service will continue to run in the background as shown in "Work-Around 1" down below (or alternatively use "Work-Around 2" solution). This also makes the app work more like iOS.
BroadcastReceiver has this same issue. If you don't unregister a BroadcastReceiver before exiting the app, then the next time you launch the app, you'll be stuck at the splash screen.
Steps to reproduce:
- Set up a Classic Titanium app using the below code an XML settings.
- Build and run on Android.
- Press the back button to exit the app.
- Re-launch the app.
- Notice that you're stuck on the splash screen. (This is the issue.)
For the 1st window you open, set it's exitOnClose property to false like the below. This prevents the back button from closing your root window and makes the app work more like iOS. It also allows the service to operate in the background without issue. This is the best solution.
Override the root window's "androidback" event and use an intent to home-out of the app. This is similar to the work-around 1 solution where the root window is not closed and the service will continue to run in the background. Again, this makes your app effectively work like iOS.
Stop the service when the root window is about to close and let everything terminate.