Packet Listener In Android Service
I am trying to create a service for a chat widget using XMPP, which picks up chat messages when they are sent to the user. I have created a service, and in the onStart I use a Asyn
Solution 1:
I have created a service, and in the onStart I use a AsyncTask to connect to the chat server, and then sets up a packetlistener.
I do not recommend that. Create your own thread, not an AsyncTask
. AsyncTask
is designed for things that will end in milliseconds or seconds, not minutes or hours.
Is the service getting stopped somehow?
Quite possibly. Use adb logcat
, DDMS, or the DDMS perspective in Eclipse to examine LogCat and see what it tells you about your code.
You should be using startForeground()
in your service, particularly if you plan on keeping the service running when your chat client activity is not necessarily in the foreground.
Post a Comment for "Packet Listener In Android Service"