Is it possible to creating a Service without starting it?
Posted
by
ThaMe90
on Stack Overflow
See other posts from Stack Overflow
or by ThaMe90
Published on 2011-02-17T12:34:33Z
Indexed on
2011/02/18
15:25 UTC
Read the original article
Hit count: 170
android
Hello all,
I wonder, is it possible to create a Service
, set some data, and then start it? I haven't come across a thread specific to this problem, so I would like to know if it is possible (if it is known of course).
My problem is that I have a Service
which listens to a DatagramSocket
, but the socket in question needs to be set after creation, but before the start of the Service
. The setting of the socket happens through the use of a Broadcast
(I broadcast 2 Strings
which hold the IP-Address & Port and the BroadcastReceiver
then constructs a socket for me).
When the Service
is started, a Thread
will start to run and listen to the supposedly created socket. This, sadly, doesn't happen. The socket will remain null
and I can't set it when the Thread
is running (This is another issue I hope to tackle in the future, if anybody got any ideas about this, please notify me).
So, is what I want possible, or should I come up with another construct for achieving this goal?
© Stack Overflow or respective owner