[TIMOB-5749] Android: AndroidManifest.xml not properly created when using Ti.Geolocation events
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-10-19T01:16:53.000+0000 |
Affected Version/s | Release 1.7.2, Release 1.7.3 |
Fix Version/s | 2013 Sprint 21, 2013 Sprint 21 Core, Release 3.2.0 |
Components | Android, Tooling |
Labels | android, androidbuild, ay-verified, dr-list, geolocation |
Reporter | Tony Lukasavage |
Assignee | Chris Barber |
Created | 2011-10-13T11:37:16.000+0000 |
Updated | 2013-11-12T12:05:44.000+0000 |
Description
Using the code below, the appropriate entries are not added to the AndroidManifest.xml file to allow for using location services.
var win = Ti.UI.createWindow();
win.open();
var locationAdded = false;
var handleLocation = function(e) {
if (!e.error) {
Ti.API.info(e.coords);
}
};
var addHandler = function() {
if (!locationAdded) {
Ti.Geolocation.addEventListener('location', handleLocation);
locationAdded = true;
}
};
var removeHandler = function() {
if (locationAdded) {
Ti.Geolocation.removeEventListener('location', handleLocation);
locationAdded = false;
}
};
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
Ti.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS;
if (Ti.Geolocation.locationServicesEnabled) {
addHandler();
var activity = Ti.Android.currentActivity;
activity.addEventListener('destroy', removeHandler);
activity.addEventListener('pause', removeHandler);
activity.addEventListener('resume', addHandler);
} else {
alert('Please enable location services');
}
The expected values of
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
are absent from the generated AndroidManifest.xml. If you add the following line of code into the above code, the AndroidManifest.xml generates just fine.
Ti.Geolocation.getCurrentPosition(function(e) {});
PR: https://github.com/appcelerator/titanium_mobile/pull/4781
The respective values are getting added in AndroidManifest.xml as