Thanks for your replay. Can you give me a example .
On Oct 16, 2:55 pm, Farproc <farp...@gmail.com> wrote: > First, you do not have to start/stop a service from a Activity. You > can > do that in anywhere via a Context object(which is very easy to > retrieve). > > If you want to start a service, just call Context.startService(), > form > then on the service will keep running in background until you > explicitly > call Context.stopService(). Then call Context.bindService() if you > want > to control the service and Context.unbindService() when you do not > want to communicate with the service anymore. > > Finally, Call Context.stopService() to terminate the service when it > is > not needed. > > ps: Though a service runs in "background", it runs in the main(UI) > thread. > > On 10月16日, 下午12时38分, pink 444 <pnk...@gmail.com> wrote: > > > Hai, > > > My application has a background process which continuously waits > > on a socket for receiving messages and it should be started only once > > and at the time of application starting.Thus i want to do that > > background job in a service. > > > The service should not be started from the activity ,it should be > > started at the application starting. > > > How can i define the service,which will be started at the time of > > application starting? > > > If at all the service is started from activity.The activity can be > > destroyed > > and restarted.when this happens the service also be restarted . > > > Any help will be appreciated highly. > > > Thanks, > > -SIva. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---