{ "id": "94043", "key": "TIMOB-9831", "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": "13574", "description": "Sprint 2012-15 Core", "name": "Sprint 2012-15 Core", "archived": true, "released": true, "releaseDate": "2012-07-30" }, { "id": "14096", "description": "Release 2.1.2", "name": "Release 2.1.2", "archived": true, "released": true, "releaseDate": "2012-08-31" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-08-15T11:03:26.000+0000", "created": "2012-06-28T08:51:04.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "core", "module_notification_manager", "qe-testadded" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [ { "id": "19456", "type": { "id": "10020", "name": "Depends", "inward": "is dependent of", "outward": "depends on" }, "outwardIssue": { "id": "97528", "key": "TIMOB-10012", "fields": { "summary": "Android: App intermittently crashes on app restart", "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": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "34055", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "115988", "key": "AC-2493", "fields": { "summary": "Android service does not run after app close if started in event", "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" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2013-12-31T13:39:36.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": "h2. Problem description\r\nA background service in Android stops running when the user exits the app using the BACK button. The same service works fine if the app is in foreground or in background (clicking the HOME button).\r\n\r\nh2. Steps to reproduce\r\n- Create an app as explained in this GIST: https://gist.github.com/e309f6a56ea6cb1fd394\r\n- Run the app on Android: as soon as the app starts, a notification is shown every 10 seconds\r\n\r\nAfter that, there are 3 cases:\r\n1. Keep the app running: every 10 seconds a notification is shown (OK).\r\n2. Put the app in background by clicking the HOME button: notifications keep showing (OK)\r\n3. Click the BACK button (this closes the app): the background service is stopped and no more notifications are shown (BUG)\r\n\r\nh2. Expected behavior\r\nAlso in case #3, the notifications should keep running every 10 seconds.\r\n\r\nh2. Customer ticket\r\nhttp://support.appcelerator.com/tickets/APP-829749", "attachment": [], "flagged": false, "summary": "Android: background services stop when the app is closed via the BACK button", "creator": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 2.0.2GA\r\nAndroid 4.0 ICS", "comment": { "comments": [ { "id": "210576", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "h3. Testing Notes\r\n\r\n* Create a new app and use the code in the Gist referred to in this item's description. That means including the notification.js and the section of the tiapp.xml, in addition to an app.js. But then replace the app.js with this code, which includes a way to stop the Service, which is needed in order to test that indeed the runtime still shuts down when no activities or services are running.\r\n\r\n{code:title=\"app.js\"}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor: 'black'\r\n});\r\n\r\nvar label = Ti.UI.createLabel({\r\n\ttext: 'A service is now running: you will see a notification every 10 seconds',\r\n\twidth: Ti.UI.SIZE,\r\n\ttop: 10,\r\n\tcolor: 'white'\r\n});\r\n\r\nwin.add(label);\r\n\r\n// create the background service\r\nvar SECONDS = 10; // every 10 seconds\r\nvar intent = Titanium.Android.createServiceIntent({\r\n url: 'notification.js'\r\n});\r\nintent.putExtra('interval', SECONDS * 1000); // Needs to be milliseconds\r\n\r\nif (!Ti.Android.isServiceRunning(intent)) {\r\n\tTitanium.Android.startService(intent);\r\n}\r\n\r\nvar btnStop = Ti.UI.createButton({title: \"Stop service\"});\r\nwin.add(btnStop);\r\nbtnStop.addEventListener(\"click\", function() {\r\n\tTi.Android.stopService(intent);\r\n});\r\n\r\nwin.open();\r\n{code}\r\n\r\n* Put this in your test app's tiapp.xml:\r\n\r\n{code}\r\ntrue\r\n{code}\r\n\r\n* Run the app on device or simulator.\r\n\r\n* When the app starts, you'll notice right away a notification in the notification area. Another is added each 10 seconds. You don't need to do anything with these notifications, just notice that they are there and happening each 10 seconds.\r\n\r\n* Back out of the app.\r\n\r\n* In the fail case, no more notifications will come in the 10-sec intervals. When testing the fix, they *should* continue to come.\r\n\r\n* When testing the fix: go back into the app after you are satisfied that the notifications are still coming in every 10 seconds.\r\n\r\n* Click the \"Stop service\" button.\r\n\r\n* Back out of the app.\r\n\r\n* Check logcat. You should see:\r\n\r\n{code}\r\nD/KrollRuntime(xxxx): Disposing runtime.\r\n{code}\r\n\r\nThat proves that the runtime does indeed shutdown (which is good for memory) when there are no more running services or activities that need it.\r\n", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-07-30T15:37:10.000+0000", "updated": "2012-07-30T16:26:17.000+0000" }, { "id": "210577", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR ready now:\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/2658", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-07-30T15:38:50.000+0000", "updated": "2012-07-30T15:38:50.000+0000" }, { "id": "214472", "author": { "name": "etcarev", "key": "etcarev", "displayName": "Evgenii Tcarev", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed with:\r\nTitanium Studio, build: 2.1.1.201207271312\r\nSDK version: 2.2.0.v20120813184911\r\n\r\nDevices:\r\nLG VS910 4G (2.3.6)\r\nSamsung Galaxy Nexus (4.0.4)\r\n", "updateAuthor": { "name": "etcarev", "key": "etcarev", "displayName": "Evgenii Tcarev", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-14T16:02:56.000+0000", "updated": "2012-08-14T16:02:56.000+0000" }, { "id": "214589", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopen to update label", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-15T11:02:57.000+0000", "updated": "2012-08-15T11:02:57.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }