{ "id": "155791", "key": "TIMOB-24304", "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": "18928", "name": "Release 6.0.2", "archived": false, "released": true, "releaseDate": "2017-02-27" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-02-16T00:28:48.000+0000", "created": "2016-03-17T08:19:13.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [ { "id": "18154", "name": "Release 6.0.1", "archived": false, "released": true, "releaseDate": "2016-12-21" } ], "issuelinks": [], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-02-16T02:02:29.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": "File: android/modules/geolocation/src/java/ti/modules/titanium/geolocation/GeolocationModule.java\r\n\r\nMethod:\r\nhasLocationPermissions()\r\n\r\nThe method checks permission on the current Activity, but it might be null when running in a service.\r\n\r\nOne solution is to change \r\n\r\nActivity currentActivity = TiApplication.getInstance().getCurrentActivity();\r\nif (currentActivity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {\r\n\r\nTo\r\n\r\nContext context = TiApplication.getInstance().getApplicationContext();\r\nif (context.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {", "attachment": [ { "id": "61242", "filename": "backgroundService.zip", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-12T18:55:07.000+0000", "size": 3737387, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: Fetching Geolocation from background service causes crash on SDK > 22", "creator": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "subtasks": [], "reporter": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "environment": null, "closedSprints": [ { "id": 796, "state": "closed", "name": "2017 Sprint 02 SDK", "startDate": "2017-01-15T00:00:41.845Z", "endDate": "2017-01-29T00:00:00.000Z", "completeDate": "2017-01-30T21:10:44.640Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "380114", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nPlease provide a sample test code to test. It will be helpful to validate the issue if we are also able to regenerate the issue in our environment. Please provide a sample regeneratable code. and also steps to follow.\r\n\r\nThanks.\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-03-18T16:39:12.000+0000", "updated": "2016-03-18T16:39:12.000+0000" }, { "id": "381153", "author": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "body": "Steps to follow:\r\n1. Run the code below:\r\n2. Make sure the main app is killed by force closing.\r\n3. The service should start after the service interval. This will make the service crash since Activity is not accessible from the service once the main Activity has been killed.\r\n\r\n\r\nExample code:\r\n\r\nFile: myservice.js:\r\n\r\nvar service = Titanium.Android.currentService;\r\nvar intent = service.intent;\r\nTi.Geolocation.getCurrentPosition(function(e) {}); // This will make \r\n\r\n\r\nFile: tiapp.xml:\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\nFile: app.js:\r\n\r\nvar intent = null, service = null;\r\nintent = Titanium.Android.createServiceIntent({\r\n url : 'myservice.js',\r\n\tstartMode : Titanium.Android.START_STICKY\r\n});\r\nintent.putExtra('interval', 10000);\r\nif(!Titanium.Android.isServiceRunning(intent)) {\r\n service = Titanium.Android.startService(intent); \r\n}\r\n\r\n", "updateAuthor": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "created": "2016-03-31T08:28:41.000+0000", "updated": "2016-03-31T08:28:41.000+0000" }, { "id": "381804", "author": { "name": "adampax", "key": "adampax", "displayName": "Adam Paxton", "active": true, "timeZone": "America/New_York" }, "body": "Code has been added as requested, is this ticket to be reopened?", "updateAuthor": { "name": "adampax", "key": "adampax", "displayName": "Adam Paxton", "active": true, "timeZone": "America/New_York" }, "created": "2016-04-05T21:31:57.000+0000", "updated": "2016-04-05T21:31:57.000+0000" }, { "id": "381835", "author": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi\r\n\r\nOk, great, can you please give us the PR so we can track when the change is out for us to use in the SDK?\r\n\r\n/Jörgen", "updateAuthor": { "name": "buder", "key": "buder", "displayName": "Jörgen Buder", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-06T06:47:23.000+0000", "updated": "2016-04-06T06:47:23.000+0000" }, { "id": "381854", "author": { "name": "adampax", "key": "adampax", "displayName": "Adam Paxton", "active": true, "timeZone": "America/New_York" }, "body": "@Sharif AbuDarda please see Jorgen's example above in response to your original request. ", "updateAuthor": { "name": "adampax", "key": "adampax", "displayName": "Adam Paxton", "active": true, "timeZone": "America/New_York" }, "created": "2016-04-06T11:32:59.000+0000", "updated": "2016-04-06T11:35:46.000+0000" }, { "id": "403975", "author": { "name": "sulaimaanrawoot", "key": "sulaimaanrawoot", "displayName": "sulaimaanrawoot", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi, what was the resolution for this?\r\n\r\nI am experiencing the same behaviour. \r\n\r\nAndroid 6, Titanium SDK 6.0.1", "updateAuthor": { "name": "sulaimaanrawoot", "key": "sulaimaanrawoot", "displayName": "sulaimaanrawoot", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-01-03T10:05:08.000+0000", "updated": "2017-01-03T10:05:08.000+0000" }, { "id": "403980", "author": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "body": "The problem is that an Activity might not be present in the service.\r\nI patched GeolocationModule.java and switched Activity->Context, like this:\r\n\r\n \\- Activity currentActivity = TiApplication.getInstance().getCurrentActivity();\r\n \\- if (currentActivity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {\r\n + Context context = TiApplication.getInstance().getApplicationContext();\r\n + if (context.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {", "updateAuthor": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "created": "2017-01-03T12:53:12.000+0000", "updated": "2017-01-03T12:53:49.000+0000" }, { "id": "404082", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Starting from Android 6.0 (API level 23), users need to grant certain permissions to apps while the app is running. \"android.permission.ACCESS_FINE_LOCATION\" is one of them. You can read it more [here|https://developer.android.com/training/permissions/requesting.html]. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-04T15:09:35.000+0000", "updated": "2017-01-04T15:43:09.000+0000" }, { "id": "404138", "author": { "name": "sulaimaanrawoot", "key": "sulaimaanrawoot", "displayName": "sulaimaanrawoot", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi, I get that but when I check if the user has the permission or I request the permission in the background service then it throws the error.", "updateAuthor": { "name": "sulaimaanrawoot", "key": "sulaimaanrawoot", "displayName": "sulaimaanrawoot", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-01-05T12:03:56.000+0000", "updated": "2017-01-05T12:03:56.000+0000" }, { "id": "404547", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "I can verify the issue in SDK 6.0.1.GA. In Android 6.0.1 device. I am using the attached project. Below is the steps. On first build on device. \r\n\r\n 1.Clicked on start. location service permission popup appears. Clicked on \"allow\".\r\n 2.Put the app on background. There is no error. Also, the service is not invoked. \r\n 3.Put the app on foreground, and Clicked on start, the service started and Hits location.\r\n 4.Put the app on background. There is the error.\r\n\r\nNow, If I rebuild on the same device again.\r\n\r\n 1.Clicked on start, no location service permission popup appears now. \r\n 2.The service invoked. Put the app on background. There is the error. \r\n\r\nThanks.\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-12T19:11:28.000+0000", "updated": "2017-01-12T19:11:28.000+0000" }, { "id": "405267", "author": { "name": "sulaimaanrawoot", "key": "sulaimaanrawoot", "displayName": "sulaimaanrawoot", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Has there been no progress on this yet?", "updateAuthor": { "name": "sulaimaanrawoot", "key": "sulaimaanrawoot", "displayName": "sulaimaanrawoot", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-01-25T10:56:12.000+0000", "updated": "2017-01-25T10:56:12.000+0000" }, { "id": "405595", "author": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "body": "Same problem found in:\r\n\r\nandroid/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java\r\nandroid/modules/platform/src/java/ti/modules/titanium/platform/PlatformModule.java", "updateAuthor": { "name": "jonasbjurhult", "key": "jonasbjurhult", "displayName": "Jonas Bjurhult", "active": true, "timeZone": "Europe/Stockholm" }, "created": "2017-01-30T06:18:10.000+0000", "updated": "2017-01-30T06:18:10.000+0000" }, { "id": "406035", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8800", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-02-01T13:18:31.000+0000", "updated": "2017-02-01T13:18:31.000+0000" }, { "id": "406586", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master: https://github.com/appcelerator/titanium_mobile/pull/8819", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-02-08T16:08:36.000+0000", "updated": "2017-02-08T16:08:36.000+0000" }, { "id": "407136", "author": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "body": "NPM Version: 2.15.9\r\nNode Version: 4.5.0\r\nMac OS: 10.12.1\r\nAppc CLI: 6.1.0\r\nAppc CLI NPM: 4.2.8\r\nAppcelerator Studio, build: 4.8.1.201612050850\r\nAndroid Device 6.0.1\r\nSDK 6.0.2 and 6.1.0\r\n\r\nFR Passed. I followed the steps in the instruction detailed in the ticket. After launching the app, I clicked on \"Start\", and then put the app in the background. Then I brought the app in the foreground and clicked \"Start\" again. I then put the app in the background. No errors were seen during the test.", "updateAuthor": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-02-16T00:28:37.000+0000", "updated": "2017-02-16T01:58:04.000+0000" }, { "id": "407141", "author": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixes are verified in installed versions:\r\nSDK 6.1.0.v20170215164209\r\nSDK 6.0.2.v20170215162535", "updateAuthor": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-02-16T02:02:09.000+0000", "updated": "2017-02-16T02:02:09.000+0000" } ], "maxResults": 16, "total": 16, "startAt": 0 } } }