[TIMOB-15094] Android: Support Titanium.App pause/resume events
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | In Review |
Resolution | Unresolved |
Affected Version/s | Release 3.1.2 |
Fix Version/s | n/a |
Components | Android |
Labels | exalture |
Reporter | Fokke Zandbergen |
Assignee | Unknown |
Created | 2013-09-06T14:19:01.000+0000 |
Updated | 2018-02-28T20:04:04.000+0000 |
Description
Like discussed in TIMOB-7360 (SDK 1.8.x) Android natively doesn't really support
pause
/resume
events for the app as a whole, but only for separate activities within the app.
However, since both closing the current heavyweight window and closing the app fire the exact same pause
event on that window, there is no way to workaround, making this a critical issue!
Having talked about this with several developers and trying multiple workarounds without much success, [~rborn] remembered [~iamyellow] actually did got this working in a [fork of the 2.1.x Titanium SDK](https://github.com/iamyellow/titanium_mobile/commits/2_1_X_iamyellow).
I have cloned the current branch and it seems the 2 commits involved should still work. I can't get the SDK to build on my system (never been there) to verify, but since this is such an frustrating parity problem I kindly ask to have a look at the 2 commits and consider pulling them into the SDK.
I know [~iamyellow] would be happy to be of help.
* Main commit: https://github.com/iamyellow/titanium_mobile/commit/42ccc574cd2a285b68aebfa4a4bb88fd9b8becce
* Commit to fix triggering the events for TiLaunchActivity
's: https://github.com/iamyellow/titanium_mobile/commit/73ed97415bf9a12ca1d1849eba4c889f6b51f4ba
The only downside that I see to this would be if someone were to ever build a Titanium App which has a Android Widget activity. I wouldn't want pause/resume to impact both the main activity (the app) and the widget activity together. Currently, the only way to do an Android Widget with Titanium is via a module and the AndroidManifest.xml file.
Never heard anyone doing an Android Widget in Titanium and I'm sure we can add a check for that?
You've never heard of it because I'm working on that module right now.
Any progress on this? I know it's a hack and that Android natively doesn't really support watching if an app (task) goes to the background and foreground, but this really would be useful in lots of cases, like: * Updating content when a user returns to the app * Pausing app-wide (multiple activities, so
allowBackground
must betrue
) music * ..This would be really useful for my needs. I need to do a particular check every time the app resumes, works a treat on iOS. It seems a shame for me to have to add an event to every single window on the off chance that it might be the one that was last active when I need to perform something on a global scope.
https://github.com/appcelerator/titanium_mobile/pull/6402 Added support for app 'pause' and 'resume' events