{ "id": "119454", "key": "TIMOB-15038", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "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": "15691", "description": "2013 Sprint 19", "name": "2013 Sprint 19", "archived": true, "released": true, "releaseDate": "2013-09-20" }, { "id": "15693", "description": "2013 Sprint 19 API", "name": "2013 Sprint 19 API", "archived": true, "released": true, "releaseDate": "2013-09-20" }, { "id": "15593", "description": "Release 3.1.3", "name": "Release 3.1.3", "archived": true, "released": true, "releaseDate": "2013-09-18" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-09-09T17:28:34.000+0000", "created": "2013-09-04T16:45:54.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2013-09-10T10:23:52.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": "h6.Issue\r\nAndroid pause and resume events does not play nice on 3.1.2.GA. Noticeable by just to pop up an customized alert on launch of the app and whenever user come from background to foreground. User need to pop up an alert while coming back to foreground. \r\n\r\nForgive me if I've missed something obvious but when I tested it out on 3.2.0.v20130830182135 SDK does not exhibit the issue. Looks like getActivity() is being fired slightly different and is used along with Window-Open method since docs mention: \r\n\r\n\"The activity is not created until the window is opened. When a window is created, its activity property refers to an empty JavaScript object.\"\r\n\r\nFurthermore: \r\n\r\n\"When the Don't keep activities option is enabled, the lifecycle of the activity is different from the normal case. Whenever the user leaves an activity, such as backgrounding the app using the HOME button, this activity is destroyed by Android, which calls onDestroy. In the normal case, onStop would be called and the activity would not be destroyed. Later, when the user goes back to that activity, this activity will be recreated, which calls onCreate. In the normal case, since the activity is not destroyed, onRestart would be called instead.\"\r\n\r\nh6.Tested on\r\nThis was tested in device with Android 4.1.2 (S3) and 2.3.5 (Droid Razr).\r\n\r\nh6.Steps to reproduce\r\n(1) From window 1 go to --> window 2 \r\n(2) Press Home (watch output logs)\r\n(3) Again click the app icon.\r\n(4) Expected ( Alert msg to pop up ) although no alerts appears.\r\n\r\nh6.3.1.2.GA\r\nOn first attempt to get value of the activity, no logs are printed. User have to go back window 1 (via back button) and open window 2 so resume state can be registered, so to speak. \r\n{code}\r\n09-04 11:25:08.331: I/TiAPI(7452): RED WINDOW - PAUSED \r\n09-04 11:25:08.409: D/Window(7452): Checkpoint: postWindowCreated()\r\n09-04 11:25:08.417: I/TiAPI(7452): BLUE WINDOW OPENED\r\n09-04 11:25:08.432: I/TiAPI(7452): BLUE WINDOW - RESUME \r\n09-04 11:25:08.432: I/ALERT(7452): (KrollRuntimeThread) [3388,26746] BLUE WINDOW - RESUME \r\n{code}\r\n\r\nh6.3.2.0.v20130830182135\r\nWhen user follows steps to reproduce activity states are fired properly.\r\n{code}\r\n09-04 10:59:57.328: I/TiAPI(5889): BLUE WINDOW OPENED\r\n09-04 10:59:57.344: I/TiAPI(5889): BLUE WINDOW - RESUME \r\n09-04 10:59:57.344: I/ALERT(5889): (KrollRuntimeThread) [27114,27114] BLUE WINDOW - RESUME \r\n{code}\r\n\r\nh6.Snippet\r\n- app.js\r\n{code}\r\nfunction destroy() {\r\n\t//Was the app destroyed correctly\r\n\tTi.API.info(\" ### STATE: DESTROY\");\r\n}\r\n\r\nTi.Android.currentActivity.addEventListener(\"destroy\", destroy);\r\n\r\n//Simple UI - my root window ...\r\nvar window = Ti.UI.createWindow({\r\n\tbackgroundColor : 'red',\r\n\texitOnClose : true,\r\n\tfullscreen : false,\r\n\t//modal: true,\r\n\tnavBarHidden : false\r\n});\r\nwindow.addEventListener('open', function() {\r\n\tTi.API.info(' RED WINDOW OPENED');\r\n\twindow.getActivity().addEventListener('pause', function(e) {\r\n\t\tTi.API.info(' RED WINDOW - PAUSED ');\r\n\t\t//alert(' RED WINDOW - PAUSED ');\r\n\t});\r\n\twindow.getActivity().addEventListener('resume', function(e) {\r\n\t\tTi.API.info(' RED WINDOW - RESUME ');\r\n\t\talert(' RED WINDOW - RESUME ');\r\n\t});\r\n});\r\nwindow.addEventListener('click', function() {\r\n\tvar win = require('window')();\r\n\twin.open();\r\n});\r\nwindow.open(); \r\n{code}\r\n\r\n- window.js\r\n{code}\r\nfunction object() {\r\n\tvar window = Ti.UI.createWindow({\r\n\t\tbackgroundColor : 'blue',\r\n\t\texitOnClose : false,\r\n\t\tfullscreen : false,\r\n\t\t//modal: true,\r\n\t\tnavBarHidden : false\r\n\t});\r\n\r\n\twindow.addEventListener('open', function() {\r\n\t\tTi.API.info(' BLUE WINDOW OPENED');\r\n\t\twindow.getActivity().addEventListener('pause', function(e) {\r\n\t\t\tTi.API.info(' BLUE WINDOW - PAUSED ');\r\n\t\t\t//alert(' BLUE WINDOW - PAUSED ');\r\n\t\t});\r\n\t\twindow.getActivity().addEventListener('resume', function(e) {\r\n\t\t\tTi.API.info(' BLUE WINDOW - RESUME ');\r\n\t\t\talert(' BLUE WINDOW - RESUME ');\r\n\t\t});\r\n\t});\r\n\r\n\twindow.addEventListener('click', function() {\r\n\t\tTi.API.info(' BLUE WINDOW CLICKED');\r\n\t\t//alert(' BLUE WINDOW CLICKED');\r\n\t});\r\n\r\n\treturn window;\r\n}\r\n\r\nmodule.exports = object;\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Unable to pop an alert while coming back to foreground", "creator": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "TiSDK 3.1.2.GA\r\nAndroid 2.3.5 (Razr) & 4.1.2 (S3) ", "comment": { "comments": [ { "id": "270352", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This appears to have been fixed as a side effect of another issue.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-09-09T17:28:34.000+0000", "updated": "2013-09-09T17:28:34.000+0000" }, { "id": "270558", "author": { "name": "djha", "key": "djha", "displayName": "Dhirendra Jha", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test Environment - \nAppc Studio: 3.1.3.201309072408\nSDK: 3.1.3.v20130909192251\nacs: 1.0.6\nAlloy: 1.2.2-beta\ntitanium: 3.1.2\ntitanium-code-processor: 1.0.2\nDevices: Nexus 7 (v4.3), Galaxy Note (v2.3.6)\n\nFollowed the steps and used the same code mentioned in the issue. Now Alert popup appears on coming back to foreground. See below the log details - \n\nNexus 7 (v4.3), Nexus 4 (v4.0.4)\n--------------------------------------------\n09-10 15:27:57.484: I/TiAPI(16603): BLUE WINDOW OPENED\n09-10 15:27:57.484: I/TiAPI(16603): BLUE WINDOW - RESUME \n09-10 15:27:57.484: I/ALERT(16603): (KrollRuntimeThread) [87,5087] BLUE WINDOW - RESUME \n09-10 15:28:09.856: I/TiAPI(16603): BLUE WINDOW - PAUSED \n09-10 15:28:24.009: I/TiAPI(16603): BLUE WINDOW - RESUME \n09-10 15:28:24.009: I/ALERT(16603): (KrollRuntimeThread) [25982,31606] BLUE WINDOW - RESUME\n-------------------------\n\nSamsung Galaxy Note (v2.3.6)\n-------------------------------------------------\n09-10 14:56:07.670: I/TiAPI(5694): BLUE WINDOW OPENED\n09-10 14:56:15.590: I/TiAPI(5694): BLUE WINDOW - PAUSED \n09-10 14:56:32.330: I/TiAPI(5694): BLUE WINDOW - RESUME \n09-10 14:56:32.330: I/ALERT(5694): (KrollRuntimeThread) [38415,38702] BLUE WINDOW - RESUME \n------------------------------------\nTested this issue using SDK 3.1.3.v20130909192251 build and working as expected. Hence closing this issue.", "updateAuthor": { "name": "djha", "key": "djha", "displayName": "Dhirendra Jha", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-09-10T10:21:33.000+0000", "updated": "2013-09-10T10:21:33.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }