Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5749] Android: AndroidManifest.xml not properly created when using Ti.Geolocation events

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-10-19T01:16:53.000+0000
Affected Version/sRelease 1.7.2, Release 1.7.3
Fix Version/s2013 Sprint 21, 2013 Sprint 21 Core, Release 3.2.0
ComponentsAndroid, Tooling
Labelsandroid, androidbuild, ay-verified, dr-list, geolocation
ReporterTony Lukasavage
AssigneeChris Barber
Created2011-10-13T11:37:16.000+0000
Updated2013-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) {});

Comments

  1. Allen Yeung 2013-10-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/4781
  2. Paras Mishra 2013-11-12

    The respective values are getting added in AndroidManifest.xml as Verified fixed on: Appcelerator Studio, build: 3.2.0.201311112306 SDK:3.2.0.v20131111174605 alloy: 1.3.0 CLI : 3.2.0 Xcode:5.0.1 Device: Google nexus 7(v4.3) OS: Mac OSX 10.9

JSON Source