Android Service Never Appears To Start - Onstartcommand() Not Called
Solution 1:
Maybe you've accidentally placed the service tag outside application tag? Then the service just fails silently. Although there should be a "Unable to start service Intent..." error in the log.
Solution 2:
Be sure to declare your service in AndroidManifest.xml
<application>
...
<serviceandroid:name=".path.to.service.MyService"/></application>
Solution 3:
It seems the onCreate() method has to exit before the service can actually start. Once I removed the getSurveyManagerService() request, and once a bit of time had passed, I received the System.out messages indicating the service was starting.
Unfortunately that creates another problem: the Activity relies on the Service for its data, so I need to determine how to cause the Activity to wait for the service to start.
EDIT: My solution was to create a private subclass of my ServiceConnection in my Activity. I then overrode the onServiceConnected() method to provide the Activity with its data (populating a ListView, in this case).
Solution 4:
In my case i refactored the service class & noticed that it was not automatically refactored in manifest. So i had to manually update the fully qualified name of the service in manifest.
Post a Comment for "Android Service Never Appears To Start - Onstartcommand() Not Called"