Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-5749

Android: AndroidManifest.xml not properly created when using Ti.Geolocation events

    Details

    • Story Points:
      3

      Description

      Using the code below, the appropriate <uses-permission> 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) {});
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cbarber Chris Barber
                Reporter:
                tlukasavage Tony Lukasavage
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-4892
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration