Wednesday 27 February 2013

What is a Service in Android with Demo

 
Service : A Service is a application component that can perform long running operations in background and does not provide a user interface.A service will continue to run in background even if the user switches to another application.

A service can be of two forms:-

  1. Started – A service is started when an application component start it by calling startservice().Once started, a service can run un background indefinitely , even if the component it is destroyed.
  2. Bound – A service is bound when an application component binds to ot by calling bindServices(). A bound service offers a client server interface that allow components to interact with the service, send requests , get results and even do so across process with Inter process Communication(IPC). A bound service runs as long as another application component is bound to it.

Feature of a Service
  1. A facility for the application to tell the system about something it want to be doing in the background.This corresponds to call to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it.
  2. A facility for an application to expose some of the functionality to other application . This corresponds to calls to context.bindService(), which allows a long standing connectivity to be made to the service in order to interact with it.


    To create a application to run in the background of other current activities, one needs to create a Service. The Service can run indefinitely (unbounded) or can run at the lifespan of the calling activity(bounded).

    Please note that a Service has a different lifecycle than activities therefore have different methods. But to begin a service in the application a call to startService() which envokes the service onCreate() method and onStart() beginning running the service. - See more at: http://marakana.com/forums/android/examples/60.html#sthash.1gmztZyv.dpuf
     
    To create a application to run in the background of other current activities, one needs to create a Service. The Service can run indefinitely (unbounded) or can run at the lifespan of the calling activity(bounded).

    Please note that a Service has a different lifecycle than activities therefore have different methods. But to begin a service in the application a call to startService() which envokes the service onCreate() method and onStart() beginning running the service.


    Download the source code here

    Please note that a Service has a different lifecycle than activities therefore have different methods. But to begin a service in the application a call to startService() which envokes the service onCreate() method and onStart() beginning running the service. - See more at: http://marakana.com/forums/android/examples/60.html#sthash.1gmztZyv.dpuf

    To create a application to run in the background of other current activities, one needs to create a Service. The Service can run indefinitely (unbounded) or can run at the lifespan of the calling activity(bounded).

    Please note that a Service has a different lifecycle than activities therefore have different methods. But to begin a service in the application a call to startService() which envokes the service onCreate() method and onStart() beginning running the service. - See more at: http://marakana.com/forums/android/examples/60.html#sthash.1gmztZyv.dpuf

    To create a application to run in the background of other current activities, one needs to create a Service. The Service can run indefinitely (unbounded) or can run at the lifespan of the calling activity(bounded).

    Please note that a Service has a different lifecycle than activities therefore have different methods. But to begin a service in the application a call to startService() which envokes the service onCreate() method and onStart() beginning running the service. - See more at: http://marakana.com/forums/android/examples/60.html#sthash.1gmztZyv.dpuf

No comments:

Post a Comment