{ "id": "172854", "key": "TIMOB-26724", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2019-03-18T18:07:25.000+0000", "created": "2019-01-14T13:13:14.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "2019-cl" ], "versions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" }, { "id": "20429", "name": "Release 7.5.1", "archived": false, "released": true, "releaseDate": "2019-02-26" } ], "issuelinks": [], "assignee": null, "updated": "2019-03-18T18:07: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": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "attachment": [], "flagged": false, "summary": "Android: How to achieve a service that can continue to run at regular intervals, even if the device goes to sleep.", "creator": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "subtasks": [], "reporter": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "environment": "Operating System\r\n Name = Microsoft Windows 10 Pro\r\n Version = 10.0.17134\r\n Architecture = 32bit\r\n # CPUs = 4\r\n Memory = 17091956736\r\nNode.js\r\n Node.js Version = 8.9.1\r\n npm Version = 5.5.1\r\nTitanium CLI\r\n CLI Version = 5.1.1\r\nTitanium SDK\r\n SDK Version = 7.5.0.GA", "closedSprints": [ { "id": 1123, "state": "closed", "name": "2019 Sprint 7", "startDate": "2019-03-18T17:27:25.993Z", "endDate": "2019-03-30T17:27:00.000Z", "completeDate": "2019-03-29T18:02:37.441Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "445290", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is by Google's design. A foreground service's main purpose is to prevent the app from being terminated while backgrounded and to prevent sensor data from being \"throttled\" while backgrounded. It does not prevent the device from going to sleep.\r\nhttps://developer.android.com/about/versions/oreo/background\r\nhttps://developer.android.com/about/versions/oreo/background-location-limits\r\n\r\nThe simplest solution is to set the window's \"keepScreenOn\" property to {{true}}. Just note that this will only work while that window is in the foreground.\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Window-property-keepScreenOn\r\n\r\nAlternatively, you can use a wake-lock like you've said. This is the only means of preventing the device from going to sleep while your app is backgrounded. Just be aware that using a wake-lock perpetually in the background is considered \"naughty\" and will kill battery life. You should only use it if absolutely necessary. (Notice that Google has been going to great lengths to improve battery life and they're the ones who frown on this behavior.)\r\n\r\nTitanium's posted notifications (including foreground service notifications) will automatically apply a 3 second wake-lock if the permission is set in your \"tiapp.xml\" file as follows.\r\n{code:xml}\r\n\r\n\r\n\t\r\n\t\t\r\n\t\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nUnfortunately, Titanium does not allow you to directly control the wake-lock (ie: acquire/release). So, while our notification API allows you to increase the wake-lock time higher than 3 seconds, the problem is you don't have a means of releasing the wake-lock when you're done with it (removing the notification won't release the wake-lock). So, what you can do instead is \"update\" the foreground notification using the same notification ID based on a timer (perhaps the service's timer?) to keep the wake-lock on. That is, call the {{foregroundNotify()}} function again with the same ID. Updating a notification won't cause it to pop up at the top of the screen, however, it will still make a sound when updated so I recommend that you lower the priority and disable the sound.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-14T20:23:08.000+0000", "updated": "2019-01-14T20:23:08.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }