[TIMOB-26746] Android: Ti.App wrongly fires pause/resume event when opening/closing child windows
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-03-26T11:03:17.000+0000 |
Affected Version/s | Release 7.5.0 |
Fix Version/s | Release 8.0.1 |
Components | Android |
Labels | android, app, engSchedule, event, parity, pause, resume |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2019-01-18T04:08:24.000+0000 |
Updated | 2019-03-26T11:03:17.000+0000 |
Description
*Summary:*
Ti.App
events "pause" and "paused" must only be fired when the app is put into the background. Events "resume" and "resumed" are to be fired when the app is returned to the foreground (include cold app startup).
Android correctly does the above when put into the background and foreground.
However, Android will also fire a "pause" and "resume" event when opening or closing a child window. This does not follow iOS' behavior and is a parity issue.
*Note:*
To be fair, the current pause/resume event behavior is how it natively works with Android's individual activities. However, app developers need these events to disable sensors when backgrounded and re-enable them when put back into the foreground, which is currently difficult to do in Titanium for the moment.
*Steps to reproduce:*
Build and run the below code on Android.
Tap the "Open Child" button.
Observe the log.
Notice that pause and resume events were logged. _(This is the bug.)_
function appEventHandler(e) {
Ti.API.info("@@@ '" + e.type + "' event received.");
if ((Ti.Platform.name === "android") || (Ti.Platform.name === "windows")) {
Ti.UI.createNotification({
message: e.type,
duration: Ti.UI.NOTIFICATION_DURATION_SHORT,
}).show();
}
}
Ti.App.addEventListener("resume", appEventHandler);
Ti.App.addEventListener("resumed", appEventHandler);
Ti.App.addEventListener("pause", appEventHandler);
Ti.App.addEventListener("paused", appEventHandler);
Ti.App.addEventListener("close", appEventHandler);
var rootWindow = Ti.UI.createWindow({ title: "Parent Window" });
var openButton = Ti.UI.createButton({ title: "Open Child" });
openButton.addEventListener("click", function() {
var childWindow = Ti.UI.createWindow({ title: "Child Window" });
var closeButton = Ti.UI.createButton({ title: "Close Child" });
closeButton.addEventListener("click", function() {
childWindow.close();
});
childWindow.add(closeButton);
childWindow.open();
});
rootWindow.add(openButton);
rootWindow.open();
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10634
PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10658
FR Passed. Waiting on Jenkins build.
merged to master, 8_0_X
*Closing ticket.* Fix verified in SDK version
8.0.1.v20190325125116
and SDK Version8.1.0.v20190325115012
. Test and other information can be found at: PR (master): https://github.com/appcelerator/titanium_mobile/pull/10634 PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10658