{ "id": "172380", "key": "TIMOB-26424", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "resolution": { "id": "10000", "description": "", "name": "Done" }, "resolutiondate": "2018-10-29T23:12:47.000+0000", "created": "2018-10-01T17:23:01.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "events", "lifecycle", "parity", "pause", "resume" ], "versions": [], "issuelinks": [ { "id": "56900", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "171505", "key": "TIMOB-25962", "fields": { "summary": "Android: Ti.App.resume and Ti.App.pause Addition - Google has added Lifecycle Components (LifecycleOwner) specifically for this", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } }, { "id": "57125", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "172887", "key": "TIMOB-26746", "fields": { "summary": "Android: Ti.App wrongly fires pause/resume event when opening/closing child windows", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-01-18T14:19:47.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "- {{Ti.App}} lifecycle events are not fired\r\n\r\n{code:js}\r\nTi.App.addEventListener('resume', () => {\r\n Ti.API.info('RESUME');\r\n});\r\n\r\nTi.App.addEventListener('pause', () => {\r\n Ti.API.info('PAUSE');\r\n});\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Added Ti.App \"pause\" and \"resume\" lifecycle events", "creator": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 1078, "state": "closed", "name": "2018 Sprint 20 SDK", "startDate": "2018-09-23T16:57:58.349Z", "endDate": "2018-10-07T16:57:00.000Z", "completeDate": "2018-10-07T23:31:40.476Z", "originBoardId": 114 }, { "id": 1088, "state": "closed", "name": "2018 Sprint 22", "startDate": "2018-10-21T23:20:52.653Z", "endDate": "2018-11-04T23:20:00.000Z", "completeDate": "2018-11-04T23:29:59.423Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "442200", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Here's one thing you may need to watch out for regarding \"resume\" and the screen-lock.\r\n\r\nIf your app is in the foreground, you press the power button to turn off the screen, and then turn on the screen... the {{Activity.onResume()}} will get called while the screen-lock is displayed (you can't see your app yet). This is fine for most apps... unless they play music or video. Media is not expected to be resumed until after the screen-lock has been cleared. You have to use a {{BroadcastReceiver}} to detect if the screen-lock has been cleared.\r\n\r\nAnother interesting thing to watch out for is some screen-locks become transparent as you swipe them off to reveal the app underneath it. So, the app needs to update its content for the current orientation too.\r\n\r\nI notice that we have a \"resume\" and \"resumed\" event. Perhaps the \"resume\" can be tied to {{Activity.onResume()}} and \"resumed\" tied to after the screen-lock has been swiped away?\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-01T17:51:46.000+0000", "updated": "2018-10-01T17:51:46.000+0000" }, { "id": "442217", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master: https://github.com/appcelerator/titanium_mobile/pull/10359", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-02T16:53:27.000+0000", "updated": "2018-10-02T16:53:27.000+0000" }, { "id": "442311", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FR Passed. PR Merged.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-04T22:00:18.000+0000", "updated": "2018-10-04T22:00:18.000+0000" }, { "id": "442481", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "*Closing ticket.* Fix can now be verified in SDK version {{7.5.0.v20181008124804}}.\r\n\r\nTest and other information can be found at:\r\nhttps://github.com/appcelerator/titanium_mobile/pull/10359", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-10T11:54:16.000+0000", "updated": "2018-10-10T11:54:16.000+0000" }, { "id": "444287", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "I see this output when using the code in the PR\r\n\r\n{code:java}\r\n-- Start application log -----------------------------------------------------\r\n[INFO] TiApplication: (main) [0,0] checkpoint, app created.\r\n[INFO] MultiDex: VM with version 2.1.0 has multidex support\r\n[INFO] MultiDex: Installing application\r\n[INFO] MultiDex: VM has multidex support, MultiDex support library is disabled.\r\n[INFO] TiApplication: (main) [141,141] Analytics have been disabled\r\n[INFO] TiApplication: (main) [2633,2774] Titanium Javascript runtime: v8\r\n[INFO] TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null\r\n[WARN] art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable\r\n[INFO] test_window 1.0 (Powered by Titanium 7.5.0.2e5a7423d0)\r\n[INFO] TiApplication: (main) [260,260] Analytics have been disabled\r\n[INFO] TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.miga.testmap.Test_windowActivity@d367838\r\n[INFO] RESUME\r\n[INFO] RESUMED\r\n[INFO] PAUSE\r\n[INFO] PAUSED\r\n[DEBUG] Window: Checkpoint: postWindowCreated()\r\n[INFO] RESUME\r\n[INFO] RESUMED\r\n{code}\r\n\r\nWhy the pause/paused at the start? Is the splashscreen calling pause/resume already?\r\n\r\nAnd when extending the code with a button and a new window:\r\n{code}\r\nvar win1 = Ti.UI.createWindow({\r\n\tbackgroundColor: 'white'\r\n});\r\n\r\nTi.App.addEventListener('resume', () => {\r\n Ti.API.info('RESUME');\r\n});\r\n\r\nTi.App.addEventListener('pause', () => {\r\n Ti.API.info('PAUSE');\r\n});\r\n\r\n\r\nTi.App.addEventListener('resumed', () => {\r\n Ti.API.info('RESUMED');\r\n});\r\n\r\nTi.App.addEventListener('paused', () => {\r\n Ti.API.info('PAUSED');\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n\ttitle: \"open\"\r\n});\r\n\r\nbtn.addEventListener(\"click\",function(){\r\n\tvar win2 = Ti.UI.createWindow({\r\n\t\tbackgroundColor: 'white'\r\n\t});\r\n\twin2.open();\r\n})\r\n\r\nwin1.add(btn);\r\nwin1.open();\r\n{code}\r\n\r\nI'll get another pause-paused-resume-resumed when opening a new window. So the event is not app level but activity/window level? So I still have to manually check if a new window was opened or the app is in background?", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-12-05T20:45:34.000+0000", "updated": "2018-12-05T20:45:34.000+0000" }, { "id": "444755", "author": { "name": "arif", "key": "arif", "displayName": "Arjan", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I am wondering the same thing; currently the resume/pause events are also fired when opening/closing a new Window. How do I separate this from an app-level pause/resume?\r\n\r\nThanks", "updateAuthor": { "name": "arif", "key": "arif", "displayName": "Arjan", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2018-12-19T20:20:52.000+0000", "updated": "2018-12-19T20:20:52.000+0000" }, { "id": "445423", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Same here, this issue is not resolved yet and it's become more problematic now as the events are getting fired for all windows no matter where you add the listener in the code. Need a quick fix on this.", "updateAuthor": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-17T04:23:40.000+0000", "updated": "2019-01-17T04:23:40.000+0000" }, { "id": "445458", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~michael], [~arif], [~prashant_saini],\r\n\r\nAfter looking at it, I agree. The current pause/remove behavior does not work like iOS. Nor does it match Titanium's documentation. It's currently following the native Android Activity {{onPause()}} and {{onResume()}} behavior, which we already have callbacks for, but ultimately app devs need the ability to detect when the app is put into the background/foreground.\r\n\r\nI've written up a ticket to have this resolved in the near future. See: [TIMOB-26746]", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-18T04:13:59.000+0000", "updated": "2019-01-18T04:13:59.000+0000" }, { "id": "445459", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "body": "@Joshua, thanks for the input, but seems that we are not going to have any events even in 8.0.0.GA release, isn't it?\r\nIf yes, then we would appreciate if you can provide any proper work-arounds to know when the app was actually put in background without going through all the pains of checking the activity pause-resume events when app can be put in background anytime.", "updateAuthor": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-18T04:18:08.000+0000", "updated": "2019-01-18T04:18:08.000+0000" }, { "id": "445460", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "We're currently code freezing Titanium 8.0.0 and are only allowing show-stopper fixes. We're trying to push an RC of 8.0.0 in the near future. But I'm going to push to get this fix into 8.0.1.\r\n\r\nAs for a work-around, I think the only solution is to monitor every activity your app opens and keep a count of each one that has had its {{onStart}} callback invoked. That's currently how it has to work natively to solve this issue as well. (Internally, we can't solve the problem via Google's new {{ProcessLifecyleOwner}} support class yet.)\r\n\r\nThis \"can\" be solved by creating an Android module, but that's a lot of effort for something so small. But if you were to do it, it would have to do the same thing Titanium's internal \"GestureModule.java\" code does to start/stop its sensors in the link below (it's a small block of code). We disable sensors when backgrounded and resume sensors when brought back to the foreground.\r\n[GestureModule.java#L78|https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/gesture/src/java/ti/modules/titanium/gesture/GestureModule.java#L78]\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-18T04:39:32.000+0000", "updated": "2019-01-18T04:39:32.000+0000" }, { "id": "445465", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~prashant_saini] you still can use Bencoding.tools or this Hyperloop module: https://github.com/dieskim/Appcelerator.Hyperloop.appPauseResume as a work-around.", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-18T14:19:47.000+0000", "updated": "2019-01-18T14:19:47.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }