{ "id": "173482", "key": "AC-6216", "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": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2019-04-19T22:33:39.000+0000", "created": "2019-04-19T09:06:13.000+0000", "labels": [ "TabGroup", "android" ], "versions": [], "issuelinks": [ { "id": "57502", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "173440", "key": "TIMOB-26964", "fields": { "summary": "Android: Calling child window's close() method back to TabGroup fails if \"Don't keep activities\" is enabled", "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": "None", "id": "6" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2019-04-19T22:33:39.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": [], "description": "The new versions of Android kills apps after long time of sleeping. The requesting of BatterySafingPermission doesn't help for all devices. ;-(\r\n\r\nMy observation:\r\nif I restart the app after waking up from sleeping mode then the app seems to frozen.\r\nHere the tracelog: https://gist.github.com/AppWerft/59ca215fb603f5a29394f7fb07b00227\r\nHere my samplecode: \r\n\r\n\r\n{code:javascript}\r\n// root activity called by app.js:\r\nmodule.exports = function() {\r\n\tconst $ = Ti.UI.createTabGroup({\r\n\t\tfullscreen : false,\r\n\t\texitOnClose : true,\r\n\t\torientationModes : [ Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT ]\r\n\t});\r\n\t$.addEventListener('open', require('ui/common/main.menu'));\r\n\t$.open();\r\n};\r\n{code}\r\nAnd here the menu, calling after opening of tabgroup:\r\n{code:javascript}\r\n// main.menu.js:\r\nmodule.exports = function() {\r\n const lifecyclecontainer = arguments[0].source;\r\n\tconsole.log(\"_openevent\");\r\n\tif (!lifecyclecontainer)\r\n\t\treturn;\r\n\tvar activity = lifecyclecontainer.getActivity();\r\n\tif (activity) {\r\n\t\tconsole.log(\"_openevent activity\"); // last seen message!!!\r\n\t\tactivity.onCreateOptionsMenu = function(_menu) {\r\n\t\t\tconsole.log(\"_openevent onCreateOptionsMenu\");\r\n\t\t\tconst menuItem = _menu.menu.add({\r\n\t\t\t\ticon : Ti.App.Android.R.drawable.ic_action_audio,\r\n\t\t\t\tshowAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM,\r\n\t\t\t});\r\n\t\t};\r\n\t\tactivity.invalidateOptionsMenu();\r\n\t}\r\n};\r\n{code}\r\n\r\nSummary: the activity of tabgroup is != null, but the next statement `activity.onCreateOptionsMenu` thows an exception. The code runs on first start of app, but crashes after resuming. This issue only appears with new SDK >=7 and >=Oreo.\r\nTiming issue?\r\n\r\n\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "Android: Issue after a long time of inactivity", "creator": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "447775", "author": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "body": "With the \"Don't keep activities\" on in developer options I can trigger the crash immediately:\r\n\r\nSteps:\r\n1. Running app\r\n2. Back button\r\n3. Restart from Home screen => no issue\r\n\r\n1. Running app\r\n2. Menu button or screen off\r\n3. Restart\r\n4. Crash with log above", "updateAuthor": { "name": "titanium@webmasterei-hamburg.de", "key": "titanium@webmasterei-hamburg.de", "displayName": "Rainer Schleevoigt", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-04-19T16:25:43.000+0000", "updated": "2019-04-19T16:25:43.000+0000" }, { "id": "447802", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~titanium@webmasterei-hamburg.de], this is a known issue which is reported here: [TIMOB-26964]\r\n\r\nThis issue is scheduled to be resolved in Titanium 8.0.1. I tested the below Classic app code with that ticket's PR and have confirmed that it'll fix your issue. It displays a menu item like how you're doing it and it's definitely recreating the menu item when the activity window is being \"restored\" by the Android OS (ie: after resuming the app).\r\n{code:javascript}\r\nfunction createTab(title) {\r\n\tvar window = Ti.UI.createWindow({ title: title });\r\n\twindow.add(Ti.UI.createLabel({ text: title + \" View\" }));\r\n\tvar tab = Ti.UI.createTab({\r\n\t\ttitle: title,\r\n\t\twindow: window,\r\n\t});\r\n\treturn tab;\r\n}\r\n\r\nvar tabGroup = Ti.UI.createTabGroup({\r\n\ttabs: [createTab(\"Tab 1\"), createTab(\"Tab 2\"), createTab(\"Tab 3\")],\r\n});\r\nif (Ti.App.Android) {\r\n\ttabGroup.activity.onCreateOptionsMenu = function(e) {\r\n\t\tTi.API.info(\"@@@ onCreateOptionsMenu() called.\");\r\n\t\tvar menuItem = e.menu.add({\r\n\t\t\ttitle: \"Menu Item 1\",\r\n\t\t\tshowAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM,\r\n\t\t});\r\n\t\tmenuItem.addEventListener(\"click\", function() {\r\n\t\t\talert(\"Menu item was clicked on.\");\r\n\t\t});\r\n\t};\r\n}\r\ntabGroup.open();\r\n{code}\r\n\r\nPlease note that this is known to crash in Titanium 7.2.1 through 7.5.1.\r\nIn Titanium 8.0.0, the {{TabGroup}} appears empty instead and doesn't crash. Still not great, but at least the crash is gone. In 8.0.1, it'll work as expected.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-04-19T22:27:52.000+0000", "updated": "2019-04-19T22:30:04.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }