Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 1
Handout#5
Problem Statement: Design and implement an application using Bound
Service.
Theory:
A Service:
 It is an application component that can perform long-running
operations in the background.
 It does not provide a user interface.
 It runs in the main thread of its hosting process—the service does
not create its own thread and does not run in a separate process
(unless you specify otherwise).
 If your service is going to do any CPU intensive work or blocking
operations (such as MP3 playback or networking), you should create
a new thread within the service to do the work.
Different Forms of Services
(1) Started
Performs a single operation and does not return a result to the caller.
For example, it might download or upload a file over the network.
(2) Bound
Offers a client-server interface that allows components to interact with
the service, send requests, get results, and even do so across processes
with interprocess communication (IPC).
Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 2
Design:
Steps:
1. Create new Android Application project “BoundServiceDemo”
2. Design layout as shown in design
3. Create new Class “CounterService” which extend Binder class
4. Every Android component need to be registered in
AndroidManifest.xml file after implementation.
5. CounterService is registered using android:name attribute of the
<service> tag.
[Reference: Book -“Mobile Apps Development” by Anubhav Pradhan, Anil V Deshpande]

MobileAppDev Handout#5

  • 1.
    Mobile Application Development T.S. Indi, IT Department, WIT Solapur Page 1 Handout#5 Problem Statement: Design and implement an application using Bound Service. Theory: A Service:  It is an application component that can perform long-running operations in the background.  It does not provide a user interface.  It runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise).  If your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do the work. Different Forms of Services (1) Started Performs a single operation and does not return a result to the caller. For example, it might download or upload a file over the network. (2) Bound Offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC).
  • 2.
    Mobile Application Development T.S. Indi, IT Department, WIT Solapur Page 2 Design: Steps: 1. Create new Android Application project “BoundServiceDemo” 2. Design layout as shown in design 3. Create new Class “CounterService” which extend Binder class 4. Every Android component need to be registered in AndroidManifest.xml file after implementation. 5. CounterService is registered using android:name attribute of the <service> tag. [Reference: Book -“Mobile Apps Development” by Anubhav Pradhan, Anil V Deshpande]