In using bindService, if there are no activities bound to the service,
then the service stops running? If so, suppose I don't want that to
happen. Suppose I want the service to keep running even when all
activities that are bound to it are unbound from it?
On Jan 31, 9:27 pm, hackbod <hack...@gmail.com> wrote:
Run the RemoteService demo in the ApiDemos program, two client
activities to use startService() and bindService each, and you can
start, bind, unbind, stop, etc. and see how they interact.
On Jan 31, 7:26 pm, jtaylor <juan.anthony.tay...@gmail.com> wrote:
> In using bindService, if there are no activities bound to the service,
> then the service stops running? If so, suppose I don't want that to
> happen. Suppose I want the service to keep running even when all
> activities that are bound to it are unbound from it?
> On Jan 31, 9:27 pm, hackbod <hack...@gmail.com> wrote:
> > That's what startService() lets you do.
> > On Jan 31, 4:52 pm, jtaylor <juan.anthony.tay...@gmail.com> wrote:
> > > If when no activities are bound to a service, why not have the option
> > > for the service to continue?- Hide quoted text -
On Jan 31, 7:26 pm, jtaylor <juan.anthony.tay...@gmail.com> wrote:
> In using bindService, if there are no activities bound to the service,
> then the service stops running? If so, suppose I don't want that to
> happen. Suppose I want the service to keep running even when all
> activities that are bound to it are unbound from it?
If you want a service to run without any clients bound to it, you (or
the service) call startService() for it. Please, however, don't just
start a service and let it run forever because that is easier to do --
leaving a service running means the system needs to keep your process
around, which steals memory from others. You really should only have
a service running when it has something useful to do: retrieving data
from the network, playing music, etc.
There is one thing which was not evident for me reading the
documentation.
One can have a service that implements the startService() and the
bindService() lifecycle
at the same time. This service would have onStart, onCreate, onDestroy
and getBinder methods, would be
possible to start with both startService and bindService and if
started with startService, it will survive the
last client unbound from it. I have already implemented such a thing,
maybe I will write an example program
about it.
On Feb 1, 9:17 am, hackbod <hack...@gmail.com> wrote:
> On Jan 31, 7:26 pm, jtaylor <juan.anthony.tay...@gmail.com> wrote:
> > In using bindService, if there are no activities bound to the service,
> > then the service stops running? If so, suppose I don't want that to
> > happen. Suppose I want the service to keep running even when all
> > activities that are bound to it are unbound from it?
> If you want a service to run without any clients bound to it, you (or
> the service) call startService() for it. Please, however, don't just
> start a service and let it run forever because that is easier to do --
> leaving a service running means the system needs to keep your process
> around, which steals memory from others. You really should only have
> a service running when it has something useful to do: retrieving data
> from the network, playing music, etc.
> On Jan 31, 7:26 pm, jtaylor <juan.anthony.tay...@gmail.com> wrote:
> > In using bindService, if there are no activities bound to the service,
> > then the service stops running? If so, suppose I don't want that to
> > happen. Suppose I want the service to keep running even when all
> > activities that are bound to it are unbound from it?
> If you want a service to run without any clients bound to it, you (or
> the service) call startService() for it. Please, however, don't just
> start a service and let it run forever because that is easier to do --
> leaving a service running means the system needs to keep your process
> around, which steals memory from others. You really should only have
> a service running when it has something useful to do: retrieving data
> from the network, playing music, etc.
> There is one thing which was not evident for me reading the
> documentation.
> One can have a service that implements the startService() and the
> bindService() lifecycle
> at the same time. This service would have onStart, onCreate, onDestroy
> and getBinder methods, would be
> possible to start with both startService and bindService and if
> started with startService, it will survive the
> last client unbound from it. I have already implemented such a thing,
> maybe I will write an example program
> about it.
> On Feb 1, 9:17 am, hackbod <hack...@gmail.com> wrote:
> > On Jan 31, 7:26 pm, jtaylor <juan.anthony.tay...@gmail.com> wrote:
> > > In using bindService, if there are no activities bound to the service,
> > > then the service stops running? If so, suppose I don't want that to
> > > happen. Suppose I want the service to keep running even when all
> > > activities that are bound to it are unbound from it?
> > If you want a service to run without any clients bound to it, you (or
> > the service) call startService() for it. Please, however, don't just
> > start a service and let it run forever because that is easier to do --
> > leaving a service running means the system needs to keep your process
> > around, which steals memory from others. You really should only have
> > a service running when it has something useful to do: retrieving data
> > from the network, playing music, etc.