[TIMOB-23135] Android: "locationServicesEnabled" returns false when available on device
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-23T16:35:06.000+0000 |
Affected Version/s | Release 5.2.1 |
Fix Version/s | Release 7.1.0 |
Components | Android |
Labels | android |
Reporter | Fokke Zandbergen |
Assignee | Joshua Quick |
Created | 2016-04-01T18:29:57.000+0000 |
Updated | 2018-03-06T22:34:06.000+0000 |
Description
On an Android 6.0 device
Ti.Geolocation.locationServicesEnabled
will return false
while it works fine. On an Android 4.4.4 emulator it returns true
while it does not.
Meanwhile [documentation](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-property-locationServicesEnabled) says since Android 2.2 it will always return true
because of the "passive" location provider but looking at the [source](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-property-locationServicesEnabled) it filters that out.
var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
title: 'Click Me'
});
btn.addEventListener('click', function(e) {
console.log('Ti.Geolocation.locationServicesEnabled ' + Ti.Geolocation.locationServicesEnabled);
console.log('Ti.Geolocation.hasLocationPermissions() ' + Ti.Geolocation.hasLocationPermissions());
if (Ti.Geolocation.hasLocationPermissions()) {
getCurrentPosition();
} else {
Ti.Geolocation.requestLocationPermissions(null, getCurrentPosition);
}
});
function getCurrentPosition() {
Ti.Geolocation.getCurrentPosition(function(e) {
console.log('Ti.Geolocation.getCurrentPosition() ' + JSON.stringify(e));
});
}
win.add(btn);
win.open();
*Android 6.1*
[INFO] Ti.Geolocation.locationServicesEnabled false
[INFO] Ti.Geolocation.hasLocationPermissions() false
[INFO] Ti.Geolocation.getCurrentPosition() {"code":0,"provider":{"power":1,"name":"network","accuracy":2},"coords":{"altitude":0,"speed":0,"longitude":5.9043011,"heading":0,"latitude":52.9589968,"timestamp":1459535042207,"altitudeAccuracy":null,"accuracy":22.777000427246094},"success":true}
*Android 4.4.4*
[INFO] Ti.Geolocation.locationServicesEnabled true
[INFO] Ti.Geolocation.hasLocationPermissions() true
[ERROR] GeolocationModule: (KrollRuntimeThread) [3070,3070] Unable to get current position, location is null
[INFO] Ti.Geolocation.getCurrentPosition() {"error":"location is currently unavailable.","success":false,"code":6}
PR https://github.com/appcelerator/titanium_mobile/pull/8903/
FR passed.
Verified the fix.
Ti.Geolocation.locationServicesEnabled
returnstrue
as expected. Closing. Studio Ver: 4.9.0.201704240654 SDK Ver: 6.1.0.v20170508081747 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.2 Appc NPM: 4.2.9 Appc CLI: 6.2.0 Ti CLI Ver: 5.0.12 Alloy Ver: 1.9.11 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: > google Nexus 6 --- Android 6.0.1 > google Nexus 6P --- Android 7.1.1 > Samsung galaxy S3 --- Android 4.4.2I still have this issue with 6.1.1.
[~adriano72] Can you provide a little more detail about your particular case? We can look into it.
Hello All, I'm still getting *false* with the use of Ti.Geolocation.locationServicesEnabled. Tested this on Android device with os version 6 & 7. Turning Location services on or off returns same value. Steps i was performing to get location: 1) checking for location permission using hasLocationPermissions() --- This works perfect 2) Check whether location service is On/Off using Ti.Geolocation.locationServicesEnabled -- Returns false always. I'm using Titanium SDK: 6.3.0 Any help would be appreciated. Thanks.
I'm having the same issue.
I'm having the same issue, testing on Nexus 6 Android 7.1.1 and I'm able to reproduce this with SDK 6.3.0
Hi, Do we've any PR for this issue?
Hi all, I'm currently working on it. Sorry for the inconvenience, will update soon.
PR https://github.com/appcelerator/titanium_mobile/pull/9633
7_0_X PR https://github.com/appcelerator/titanium_mobile/pull/9682 {color:red}[This PR has been closed.]{color}
Can this be put in to the 7.0.2 release?
PR (7.1.x): https://github.com/appcelerator/titanium_mobile/pull/9840
FR's passed. PR's merged.
Verified the fix in SDK 7.2.0.v20180305152636 & 7.1.0.v20180306061214. Closing. Studio Ver: 5.0.0.201712081732 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.12 Appc CLI: 7.0.2 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 5 — Android 6.0.1 ⇨ google Nexus 6P — Android 8.0.0