{ "id": "151564", "key": "TIMOB-19920", "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": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2015-11-23T05:06:19.000+0000", "created": "2015-09-29T06:58:40.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "Community", "activity", "android" ], "versions": [], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2017-03-24T17:56:00.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": "Hi, i am working on an titanium but i have problems getting android activity life-cycle state.\r\n\r\nI have gone through http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android.Activity adding of \r\ntrue also in tiapp.xml.\r\n\r\nAdded the eventListners.\r\nvar appActivity = Ti.Android.currentActivity;\r\nappActivity.addEventListener('onResume, function() {\r\n\t Ti.API.info('Tha applicaiton was onResume'');\r\n});\r\nJust like this i have added onPause, onStart', onRestart and onStop. But still i am not getting any required output. \r\n\r\nI want to get the state of android activity and if possible also without adding any other 3rd party module.", "attachment": [], "flagged": false, "summary": "Android Lifecycle State (onPause, onCreate and others) not getting called", "creator": { "name": "bhavin2887", "key": "bhavin2887", "displayName": "Bhavin Bhavsar", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "bhavin2887", "key": "bhavin2887", "displayName": "Bhavin Bhavsar", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 3.5.1.GA\r\nTitanium SDK 3.5.0.GA\r\n", "closedSprints": [ { "id": 529, "state": "closed", "name": "2015 Sprint 24 SDK", "startDate": "2015-11-21T01:30:12.670Z", "endDate": "2015-12-05T01:30:00.000Z", "completeDate": "2015-12-07T03:57:17.094Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "365234", "author": { "name": "ahossain", "key": "ahossain", "displayName": "Amimul Hossain", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, See pull request: https://github.com/appcelerator/titanium_mobile/pull/5701\r\nSee test application below.\r\nExplanation:\r\n1. Added onCreate, onStart, onResume, onRestart, onPause, onStop, and onDestroy properties to the tab group or window activity property.\r\n2. For Window, you must set these properties prior to window.open() called.\r\n3. For TabGroup, you can set these only after the open event (it's unfortunate that the two APIs are different in this, but that's outside the scope of this PR). \r\n\r\n{code}\r\n\r\nTitanium.UI.setBackgroundColor('#000');\r\n \r\n// create tab group\r\nvar tabGroup = Titanium.UI.createTabGroup();\r\n \r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Tab 1',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab1 = Titanium.UI.createTab({ \r\n icon:'KS_nav_views.png',\r\n title:'Tab 1',\r\n window:win1\r\n});\r\n \r\nvar label1 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'Click to open window',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n \r\nfunction openWin() {\r\n\tvar childWin = Ti.UI.createWindow({});\r\n\t// For windows we set the activity lifecycle callback prior to calling open()\r\n\t// We cannnot call childWin.activity.addEventListener yet since the method is undefined\r\n\t// And if we call childWin.activity.addEventListener during the open event\r\n\t// we can miss the create, start, restart and resume events.\r\n\t// This is device and timing dependent.\r\n\t// Thus for windows we must define the callbacks here, and events should be deprecated.\r\n\tchildWin.activity.onCreateOptionsMenu = function(e){\r\n\t\tTi.API.info('childWin onCreateOptionsMenu called');\r\n\t};\t\r\n\tchildWin.activity.onStart = function(){\r\n\t\tTi.API.info('childWin onStart called');\r\n\t\t// In the \"onStart, etc callbacks this refers to the activity\r\n\t\tTi.API.info('apiName: ' + this.apiName); \r\n\t};\r\n\tchildWin.activity.onRestart = function(){\r\n\t\tTi.API.info('childWin onRestart called');\r\n\t};\r\n\tchildWin.activity.onCreate = function(){\r\n\t\tTi.API.info('childWin onCreate called');\r\n\t};\r\n\tchildWin.activity.onResume = function(){\r\n\t\tTi.API.info('childWin onResume called');\r\n\t};\r\n\tchildWin.activity.onPause = function(){\r\n\t\tTi.API.info('childWin onPause called');\r\n\t};\r\n\tchildWin.activity.onStop = function(){\r\n\t\tTi.API.info('childWin onStop called');\r\n\t};\r\n\tchildWin.activity.onDestroy = function(){\r\n\t\tTi.API.info('childWin onDestroy called');\r\n\t};\r\n\tchildWin.open();\r\n}\r\nlabel1.addEventListener('click', openWin);\r\nwin1.add(label1);\r\n \r\nvar win2 = Titanium.UI.createWindow({ \r\n title:'Tab 2',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab2 = Titanium.UI.createTab({ \r\n icon:'KS_nav_ui.png',\r\n title:'Tab 2',\r\n window:win2\r\n});\r\n \r\nvar label2 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'I am Window 2',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n \r\nwin2.add(label2);\r\n \r\ntabGroup.addTab(tab1); \r\ntabGroup.addTab(tab2); \r\n \r\ntabGroup.addEventListener('open', function() {\r\n\t// The tabGroup.activity property is valid only after open\r\n\t// we can set activity properties for synchronous callbacks\r\n\t// or tabGroup.activity.addEventListener() will also work\r\n\ttabGroup.activity.onCreateOptionsMenu = function(e){\r\n\t\tTi.API.info('tabGroup onCreateOptionsMenu called');\r\n\t};\t\r\n\ttabGroup.activity.onStart = function(){\r\n\t\tTi.API.info('tabGroup onStart called');\r\n\t};\r\n\ttabGroup.activity.onRestart = function(){\r\n\t\tTi.API.info('tabGroup onRestart called');\r\n\t};\r\n\ttabGroup.activity.onCreate = function(){\r\n\t\tTi.API.info('tabGroup onCreate called');\r\n\t};\r\n\ttabGroup.activity.onResume = function(){\r\n\t\tTi.API.info('tabGroup onResume called');\r\n\t};\r\n\ttabGroup.activity.onPause = function(){\r\n\t\tTi.API.info('tabGroup onPause called');\r\n\t};\r\n\ttabGroup.activity.onStop = function(){\r\n\t\tTi.API.info('tabGroup onStop called');\r\n\t};\r\n\ttabGroup.activity.onDestroy = function(){\r\n\t\tTi.API.info('tabGroup onDestroy called');\r\n\t};\t\r\n});\r\n \r\ntabGroup.open();\r\n{code}\r\n\r\nThanks.", "updateAuthor": { "name": "ahossain", "key": "ahossain", "displayName": "Amimul Hossain", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2015-09-29T09:25:47.000+0000", "updated": "2015-09-29T09:25:47.000+0000" }, { "id": "370942", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~bhavin2887] The comment written earlier works and you do get the lifecycle.\r\n\r\nI'll close this ticket as invalid if there is nothing else. :) ", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-11-20T04:22:10.000+0000", "updated": "2015-11-20T04:22:10.000+0000" }, { "id": "415592", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": " Closing ticket as invalid with reference to the above comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-24T17:56:00.000+0000", "updated": "2017-03-24T17:56:00.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }