Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24596] Android: Unable to get the geolocation coordinates when GPS is set to GPS only mode.

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionDone
Resolution Date2018-12-09T05:30:38.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterJebun Naher
AssigneeUnknown
Created2017-04-19T10:19:31.000+0000
Updated2018-12-09T05:30:38.000+0000

Description

*Issue Description:* On android when the device's GPS mode is set to GPS only then it fails to get the location coordinates. It occurs on android 6 using SDK 6.1.0.v20170309181051, 6.0.2GA, 6.0.1GA. On iOS it works fine. *Steps to reproduce:* 1. Run the sample code in index.js file. 2. When the app opens up it'll ask for location permission. If you grant location permission, the app will alert the coordinates. 3. But if you go into the settings of the phone and set the GPS mode to "GPS only" then the app does not return the coordinates. *Expected:* App should return the location coordinates. *Actual:* It doesn't return the location coordinates in GPS only mode. *Test Code:*
$.index.open();

if (!Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS)) {
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {

});
} else {
getGps();
}

function getGps() {

var coords = {};
var method = "";

var providerGps = Ti.Geolocation.Android.createLocationProvider({
name : Ti.Geolocation.PROVIDER_GPS,
minUpdateDistance : 0.0,
minUpdateTime : 0
});

Ti.Geolocation.Android.addLocationRule(Ti.Geolocation.Android.createLocationRule({
provider : Ti.Geolocation.PROVIDER_GPS,
accuracy : Alloy.CFG.accuracy,
maxAge : Alloy.CFG.maxAge,
minAge : Alloy.CFG.minAge
}));

Ti.Geolocation.Android.addLocationProvider(providerGps);
Ti.Geolocation.Android.manualMode = true;

Titanium.Geolocation.getCurrentPosition(function(e) {
if (e.error) {
if ( typeof errorCallback != "undefined" && errorCallback != null) {
alert(e.error);
}
} else {
method = e.provider.name;
coords = e.coords;

alert(coords);

}
});

}

Comments

  1. Rene Pot 2017-10-10

    Fused Location Provider would fix this

JSON Source