Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2866] Geolocation Location event cannot be processed in Android service

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2011-10-20T08:59:20.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, geolocation, services
ReporterFrank Apap
AssigneeMatthew Apperson
Created2011-10-17T10:37:27.000+0000
Updated2016-03-08T07:47:49.000+0000

Description

I have an android background service that start a location listener. However, once you exit from the app while the service still runs the callback isn't called. The logs show that Titanium is throwing a NPE. 10-17 12:56:05.792: ERROR/KrollEventManager(27494): (kroll$2) [2653,32869] Error invoking listener with id 2 on eventName 'location' 10-17 12:56:05.792: ERROR/KrollEventManager(27494): java.lang.NullPointerException 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.kroll.KrollProxy.createEventInvocation(KrollProxy.java:657) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.kroll.KrollProxy.fireSingleEvent(KrollProxy.java:669) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.kroll.KrollEventManager$KrollListener.invoke(KrollEventManager.java:143) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.kroll.KrollEventManager.dispatchEvent(KrollEventManager.java:273) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.kroll.KrollEventManager.dispatchEvent(KrollEventManager.java:240) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.kroll.KrollProxy.fireEvent(KrollProxy.java:642) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at ti.modules.titanium.geolocation.TiLocation.onLocationChanged(TiLocation.java:107) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:228) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:160) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:176) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at android.os.Handler.dispatchMessage(Handler.java:99) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at android.os.Looper.loop(Looper.java:150) 10-17 12:56:05.792: ERROR/KrollEventManager(27494): at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) More details / discussion can be found here: http://developer.appcelerator.com/question/126946/background-location-on-android

Comments

  1. Frank Apap 2011-10-17

    Update: Upon further testing it appears a similar issue exists in the Kitchen Sink android service examples. The log messages stop when you back out of the app even though the service still shows to be running. I think the service runs but the fireEvent doesnt work.
  2. Frank Apap 2011-10-18

    Here is simple code snippet that demonstrates the issue: (this is the service): Ti.API.info("Test Service running"); function tevt(){ Ti.API.debug("Event Ran"); Titanium.App.removeEventListener('test1',tevt); } Titanium.App.addEventListener('test1',tevt); Ti.App.fireEvent('test1');
  3. Matthew Apperson 2011-10-20

    Frank, To file a bug ticket, all relevant information needs to be included such as Android SDK version, as well at the exact build of the Ti SDK you are using. For a full outline of all required information, please see our JIRA checklist here - http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist Best regards, Matt

JSON Source