I’m having the permissions set correctly in build.settings but I cannot get the GPS to work on android devices. (Tested on Samsung Galaxy Tab 10.1 and Nexus 7). I’m pulling out hairs right now, so any help would be gladly appreciated!
Here’s my build.settings:
-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight", "landscapeLeft", } }, iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXXXXXXX", -- example scheme for facebook "coronasdkapp", -- example second scheme } } } --]] } }, -- Android permissions android = { largeHeap = true, usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.ACCESS\_COURSE\_LOCATION", }, }, }
HEre’s a relevant piece of the location code:
function instance:init() if not self.isInitialized then self.isInitialized = true Runtime:addEventListener("location", function(e) instance:handleLocationEvent(e) end) end end function instance:handleLocationEvent( event ) if event.errorCode then print( "Location error: " .. tostring( event.errorMessage ) ) else print('GPS location update') self.direction = event.direction self.accuracy = event.accuracy self.altitude = event.altitude self.longitude = event.longitude self.latitude = event.latitude end end
Thanks!