Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8751] Android: Ti.Geolocation.getPreferredProvider() crashes the app when location services are disabled

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-10T00:08:52.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-09 API
ComponentsAndroid
LabelsSupportTeam, api, module_geolocation, qe-testadded
ReporterMauro Parra-Miranda
AssigneeJosh Roesslein
Created2012-04-16T18:10:30.000+0000
Updated2012-07-10T16:21:55.000+0000

Description

Problem description

If you call Titanium.Geolocation.getPreferredProvider() and the Geo services are not enabled, the app will crash.

Actual results

The app crashes

Expected results

IF there is no geo services enabled, just warn the user.

Test Case.

1. Create a new mobile project. 2. Paste this code:
	Ti.API.info(Titanium.Geolocation.getPreferredProvider());
3. Disable Geolocation services in the device. 4. Build for device. 5. Run the app

HD Discussion

http://support-admin.appcelerator.com/display/APP-423883

Workaround

if(Titanium.Geolocation.getLocationServicesEnabled()){
	Ti.API.info(Titanium.Geolocation.getPreferredProvider());
} else {
	alert('Geo Services not enabled');
	Ti.API.info("Geo Services not enabled");
}

Comments

  1. Josh Roesslein 2012-04-26

    Note [preferredProvider](http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Geolocation-property-preferredProvider) has been deprecated. The [accuracy](http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Geolocation-property-accuracy) property is the new method for "simple mode".
  2. Josh Roesslein 2012-04-26

    Closing issue since there is a work around and the property is deprecated and will be removed.
  3. Josh Roesslein 2012-04-27

    [PR #2088](https://github.com/appcelerator/titanium_mobile/pull/2088) fixes a crash/JS error seen when trying to call getPreferredProvider(). No longer see any application crashes after applying the fix.
  4. Payminder Singh 2012-06-23

    Titanium Studio: 2.1.0.201206221045 Mobile SDK: 2.1.0.v20120622174154 OS: X Lion Device: Samsung Galaxy Fixed. App doesn't crash, nor does it provide any string information about geo location or warning message, either with Geo-location setting is enable or disable from device settings. Returned undefined
  5. Shyam Bhadauria 2012-07-10

    Re-opening to edit label

JSON Source