{ "id": "115988", "key": "AC-2493", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2013-07-09T21:53:14.000+0000", "created": "2013-06-14T22:39:38.000+0000", "labels": [ "android", "api" ], "versions": [], "issuelinks": [ { "id": "34055", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "94043", "key": "TIMOB-9831", "fields": { "summary": "Android: background services stop when the app is closed via the BACK button", "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 } } } } ], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:41:32.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": "14545", "name": "Documentation" }, { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "An android service which is started inside an App level event listener stops after the application is closed (For instance, via Recent Apps). This is not experienced when the service is started initially with the App. This can be seen when viewing running services. Normal behavior will show that there is a process and/or service running. When started from an event listener, it show app as cached process with no services or, when closed, as a terminated app. I don't know if this expected behavior or a bug, but there is not mention of this possibility in the API documentation.\r\n(Sorry if I'm filing this bug report incorrect, this is my first time). ", "attachment": [], "flagged": false, "summary": "Android service does not run after app close if started in event", "creator": { "name": "louderbj", "key": "louderbj", "displayName": "John Louderback", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "louderbj", "key": "louderbj", "displayName": "John Louderback", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Windows 7, Android", "comment": { "comments": [ { "id": "258033", "author": { "name": "louderbj", "key": "louderbj", "displayName": "John Louderback", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm so sorry, I was very much mistaken. I didn't see it until now. The difference between the two behaviors I mentioned above are not the result of being in an event listener or not, it's the difference between Ti.Android.createService(intent).start(); and Ti.Android.startService(intent);. I don't see the difference in behavior documented still. Why do these operate so vastly different from each other?", "updateAuthor": { "name": "louderbj", "key": "louderbj", "displayName": "John Louderback", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-14T22:49:09.000+0000", "updated": "2013-06-14T22:49:09.000+0000" }, { "id": "261157", "author": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello John,\n\nThe difference between the two is this:\n{code}\nTi.Android.createService(intent).start(); \n{code}\ncreates the service from an intent AND starts the service in one fell swoop.\nWhereas\n{code}\nTi.Android.startService(intent);\n{code}\ncan start a service but ONLY after is has already been created. \n\nI hope this can shed some light on your inquiry. \n\nRegards,\n\nCarter", "updateAuthor": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-09T21:52:07.000+0000", "updated": "2013-07-09T21:52:07.000+0000" }, { "id": "286359", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nWe tested this issue with the test code below. We can't reproduce this issue in the latest TiSDK build. Please check my test code and let me know if have any problem.\r\n\r\n\r\nh5. Test Environment\r\n\r\nWindows 7,\r\nTitanium SDK 3.2.0 GA\r\nAndroid 4.2.2\r\nTi CLI 3.2.0\r\n\r\n\r\nh5. Test Code\r\n\r\napp.js\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : 'black',\r\n\tlayout:'vertical'\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\\nEven after closing your apps',\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;\r\n// every 10 seconds\r\nvar intent = Titanium.Android.createServiceIntent({\r\n\turl : 'notification.js'\r\n});\r\nintent.putExtra('interval', SECONDS * 1000);\r\n// 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({\r\n\ttitle : \"Stop service\",\r\n\ttop:50\r\n});\r\nwin.add(btnStop);\r\nbtnStop.addEventListener(\"click\", function() {\r\n\tTi.Android.stopService(intent);\r\n});\r\nvar btnStart = Ti.UI.createButton({\r\n\ttitle : \"Start service\",\r\n\ttop:10\r\n});\r\nbtnStart.addEventListener(\"click\", function() {\r\n\tTitanium.Android.startService(intent);\r\n});\r\nwin.add(btnStop);\r\nwin.add(btnStart);\r\nwin.open();\r\n{code}\r\n\r\nnotification.js\r\n{code}\r\nvar intent = Ti.Android.createIntent({\r\n flags : Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_NEW_TASK,\r\n //here paste your app id and activityName like this code\r\n className : 'com.bd.motiur.MotiurRahmanActivity'\r\n});\r\nintent.addCategory(Ti.Android.CATEGORY_LAUNCHER);\r\n \r\nvar pending = Titanium.Android.createPendingIntent({\r\n intent: intent,\r\n flags: Titanium.Android.FLAG_UPDATE_CURRENT\r\n});\r\n \r\n// create a random id\r\nvar nId = parseInt(10000 * Math.random());\r\n \r\n// Create the notification\r\nvar notification = Titanium.Android.createNotification({\r\n contentTitle: 'Notification #' + nId,\r\n contentText : 'Click to return to the application.',\r\n contentIntent: pending\r\n});\r\n \r\n// Send the notification.\r\nTi.Android.NotificationManager.notify(nId, notification);\r\n{code}\r\n\r\ntiapp.xml\r\n{code}\r\nsystem\r\n \r\n \r\n \r\n \r\n \r\n{code}", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-31T13:39:36.000+0000", "updated": "2013-12-31T18:45:00.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }