Here's the deal:
I'm building a mobile app with Appcelerator Titanium. It will be deployed to iOS and Android devices.
I use the Titanium.Database module to cache incoming data that the app displays. I would like to close() the database (and maybe perform some other actions) when the user presses the home button/dismisses the app. While in the background, an app can be killed without warning (either manually or by the system), so I would like to do some clean up in anticipation of this event.
I see the 'pause', 'resume' and 'resumed' events mentioned in the API docs, but they're iOS-only.
So.... How do I take care of business on Android?
You can add an event listener to current activity in Android:
Ti.Android.currentActivity.addEventListener('pause', callback);
or
Ti.Android.currentActivity.addEventListener('resume', callback);
Maybe you are asking how to do that on iOS? I would try with a window listener to 'focus' and 'blur'.