{ "id": "119312", "key": "AC-2624", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-01-01T23:28:25.000+0000", "created": "2013-08-30T14:35:56.000+0000", "labels": [ "activity", "android", "pause", "resume" ], "versions": [], "issuelinks": [], "assignee": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:41:42.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "In theory, Ti.Android.currentActivity will work in the right way, but it actually only happens when you are using exclusively \"heavyweight\" windows.\r\n\r\nIn my project I'm using a \"custom Navigation controller\" which will create a stack of windows when needed. In order to physical back button to work without exiting the app, it is neccesary to make this trick while creating the new win in the stack: win.navBarHidden = true;\r\n\r\nThis seems to cause the problem with Android activity: when this new window is opened, the \"parent\" window goes to \"pause\" and \"stop\" states, so the app / OS already considers the app to be in the background (but in fact we are interacting with it).\r\nThis is why pause cannot fire again when you press 'home' or when a call is received... it's already 'paused'.\r\nResume also cannot fire as when the app reopens, for some reason the app is never considered to have come into the foreground!\r\nBUT if you hit the back button on the first main window, which brings you to the splash screen, then the pause and resume events works fine.\r\n\r\nThe way around is don't use the navBarHidden = true but, then, a back button press will close the entire app, instead of simple going to the previous window.\r\n\r\nHere you can see my custom NavBar, if you want to test the problem (also the full app is working now to test it, if you want): \r\nhttps://github.com/mcvendrell/Pasti/blob/master/app/lib/navigation.js\r\n\r\nMore info:\r\nhttp://developer.appcelerator.com/question/149942\r\n\r\nFor any clarification or test case, I can provide more code.", "attachment": [], "flagged": false, "summary": "Pause & Resume events don't firing right on Android ", "creator": { "name": "mcvendrell", "key": "mcvendrell", "displayName": "Manuel Conde Vendrell", "active": true, "timeZone": "Europe/Madrid" }, "subtasks": [], "reporter": { "name": "mcvendrell", "key": "mcvendrell", "displayName": "Manuel Conde Vendrell", "active": true, "timeZone": "Europe/Madrid" }, "environment": "Titanium 3.1.2GA", "comment": { "comments": [ { "id": "270502", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello,\n\nas a workaround, you can catch the android back button event and handle according to your stack of windows. \n\nbest,\n\nMAuro ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-09-10T00:30:10.000+0000", "updated": "2013-09-10T00:30:10.000+0000" }, { "id": "270503", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "In order to process this as a Ti Mobile SDK bug, we need a full testcase, adn the instructions to reproduce the issue.", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-09-10T00:31:02.000+0000", "updated": "2013-09-10T00:31:02.000+0000" }, { "id": "270562", "author": { "name": "mcvendrell", "key": "mcvendrell", "displayName": "Manuel Conde Vendrell", "active": true, "timeZone": "Europe/Madrid" }, "body": "No problem, you can reproduce it easily.\n\nTake this simple project (main window with two buttons to open a new window): https://github.com/mcvendrell/Basic-custom-NavBar\n\nJust as it is now, this problem occurs. To see how it happens, just add this lines to INDEX.JS:\n\nfunction OnAppResume(){\n Ti.API.info('***---> OnAppResume');\n}\nfunction OnAppPause(){\n Ti.API.info('***---> OnAppPause');\n}\nTi.Android.currentActivity.addEventListener('resume', OnAppResume);\nTi.Android.currentActivity.addEventListener('pause', OnAppPause);\n\nAnd launch the project. You will see that, once the first screen is opened, the PAUSE event is fired. You can now push the home button, nothing will happen. And you can launch the app again, no RESUME event will be fired.\n\nNow go to LIB/NAV.JS file and comment the line #108 win.navBarHidden = true;\n\nRelaunch the app. Now the events are fired correctly: nothing in the first screen, press home button, PAUSE is fired, recall app, RESUME is fired.\n\nFor the tip, to avoid back to close app, I'm doing exactly that: manage back button manually. But thanks for it.", "updateAuthor": { "name": "mcvendrell", "key": "mcvendrell", "displayName": "Manuel Conde Vendrell", "active": true, "timeZone": "Europe/Madrid" }, "created": "2013-09-10T11:06:52.000+0000", "updated": "2013-09-10T11:06:52.000+0000" }, { "id": "286176", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nI tested this issue with the test code bellow. I can’t reproduce this issue. It’s working perfect in Android Device. Please check my code and let me know if have any problem then send your test code and test procedure.\r\n\r\n\r\nh5. Test Environment\r\n\r\nMac OSX 10.8.5,\r\nTitanium SDK 3.2.0 GA, \r\nTi CLI 3.2.0\r\nAndroid 4.2.2 Device \r\n\r\n\r\nh5. Test code\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\n\r\nfunction OnAppResume() {\r\n\tTi.API.info('***---> OnAppResume');\r\n}\r\n\r\nfunction OnAppPause() {\r\n\tTi.API.info('***---> OnAppPause');\r\n}\r\n\r\nTi.Android.currentActivity.addEventListener('resume', OnAppResume);\r\nTi.Android.currentActivity.addEventListener('pause', OnAppPause);\r\n\r\nwin.open();\r\n\r\n{code}\r\n\r\n\r\nThanks\r\n", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-29T19:23:52.000+0000", "updated": "2013-12-31T04:15:13.000+0000" }, { "id": "286349", "author": { "name": "mcvendrell", "key": "mcvendrell", "displayName": "Manuel Conde Vendrell", "active": true, "timeZone": "Europe/Madrid" }, "body": "Mostafizur, I suppose that now, with Ti 3.2.0, will work because one of the changes made is that all the opened windows in Android are heavyweight by default and you don't need to use *win.navBarHidden = true* to transform it to heavyweight (that was the main problem).\n\nI guess that in 3.2.0 this issue has no sense.", "updateAuthor": { "name": "mcvendrell", "key": "mcvendrell", "displayName": "Manuel Conde Vendrell", "active": true, "timeZone": "Europe/Madrid" }, "created": "2013-12-31T08:29:36.000+0000", "updated": "2013-12-31T08:29:36.000+0000" }, { "id": "286428", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~mcvendrell] Resolving this ticket as fixed in 3.2.0 GA release as per the transition from light weight window to heavy weight window. Please let us know if you see any issue with this release and we would be happy to take a look.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-01T23:28:25.000+0000", "updated": "2014-01-01T23:28:25.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }