Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1753] App crashes on Android when firing synthetic geo-location event

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-01-31T17:25:05.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsalloy, android-4.2.2, geolocation
ReporterMichael Stelly
AssigneeRitu Agrawal
Created2014-01-26T20:26:39.000+0000
Updated2016-03-08T07:40:38.000+0000

Description

First, this app works as intended on iOS simulator and iPhone 5. I launch the app, navigate to my TableView, and select a row which fires the breakpoint at the custom event. Stepping through the code on my android device, I call my geoLocation event
Ti.API.fireEvent('getCurrentPosition');
which fires
Ti.App.addEventListener('getCurrentPosition', function() {
	Ti.Geolocation.getCurrentPosition(updateGeolocation);
});
which in turn calls
function updateGeolocation(e) {

	Ti.App.Properties.setDouble('geo.lat', e.coords.latitude);
	Ti.App.Properties.setDouble('geo.lon', e.coords.longitude);

	return;
}
. Upon reaching updateGeoLocation(), the app crashes with an error(see screenshot) with the console output noted in the attached text file. Something is definitely wrong with the geo-location piece because if I comment it out, I can navigate to the row's child record. I tried getting assistance on the forum, but never got any response whatsoever. Finally, when the app launches, it performs a geo-permission test like this:
function checkGeoPermission() {
	if (Ti.Geolocation.locationServicesEnabled === false) {
		helper.showDialog({
			title : 'Mapping Error',
			message : 'Your device has geo turned off - turn it on.'
		});
	} else {
		if (OS_IOS) {
			var authorization = Ti.Geolocation.getLocationServicesAuthorization();
			if (authorization == Ti.Geolocation.AUTHORIZATION_DENIED) {
				helper.showDialog({
					title : 'Mapping Error',
					message : 'You have disallowed App from running geolocation services.'
				});
			} else if (authorization == Ti.Geolocation.AUTHORIZATION_RESTRICTED) {
				helper.showDialog({
					title : 'Mapping Error',
					message : 'Your system has disallowed App from running geolocation services.'
				});
			}
		}
	}
	return;
};
I think this may be a bug with how android handles location services. If I can get help resolving it, I would be most grateful. Regards, Mike.

Attachments

FileDateSize
foodtruck-console.txt2014-01-26T20:26:39.000+000025137
Screenshot_2014-01-26-13-33-43.png2014-01-26T20:26:39.000+000068349

Comments

  1. Ritu Agrawal 2014-01-27

    I noticed that you are checking Geo permission for iOS platform but not for Android platform. Can you check for permissions on Android platform in checkGeoPermission function as well? It may also be related to not having the correct geo entry in the manifest file. Please provide a simple but complete test case to reproduce this issue.
  2. Michael Stelly 2014-01-28

    Ritu, I wasn't able to find any specific Android related location services permission checks in the api. The Ti.Geolocation.Android doc states, {quote}Manual configuration is recommended for applications that have more demanding geolocation needs (for example, driving directions). However, for basic geolocation information, *simple mode* geolocation may be sufficient.{quote} I am using simple mode, so the only check I do for android is in my init() method,
    	if (OS_ANDROID) {
       		Titanium.Geolocation.Android.LocationProvider = Ti.Geolocation.PROVIDER_GPS;
       		Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;
       	}
       
    If you know of something else in the api that I haven't found, please let me know. As for a test case, I gave you what I have. The app's table view links to an ACS table for which you don't have access, so that won't help you at all. How else can I help move this forward?
  3. Ritu Agrawal 2014-01-29

    Thanks for the update. We need a complete runnable test case that we can run as it is to reproduce exactly the same issue you are running into. You don't need to provide us access to ACS table as you should be able to reproduce this issue without ACS by putting some dummy values in the table view.
  4. Michael Stelly 2014-01-31

    Ritu, Please close. It must not be a bug, because I cannot replicate the error with a test case. Sorry to waste your time. Regards.
  5. Ritu Agrawal 2014-01-31

    No problem [~madcode].

JSON Source