Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing remote service

 
yash wardhan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to write a sample remote service, I followed the steps given on android site in tools -> AIDL.
I followed the given sample in sample folder and able to run the service when the .aidl file, service, interface, client etc are in same project.
However I want to write the service in different project and want other client applications to use that service methods.But no success.

I have some question,

1. Is it required that the service should be running to use bindService(Intent)?
2. What is differnce between startService and bindService?

Can anyone help me in this? any sample tutorial which will help in getting comfortable with writing remote Services?


Thanks in advance,
 
Mark L. Murphy
Author
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Is it required that the service should be running to use bindService(Intent)?


No, but if it is not running, you will need the BIND_AUTO_CREATE flag as the last parameter to bindService().

2. What is differnce between startService and bindService?


startService() starts the service. bindService() binds an AIDL client to an AIDL interface of the service, possibly starting it if BIND_AUTO_CREATE is included. When you later unbind from that service, if nobody else has bound to it and nobody else called startService(), the service will automatically shut down. When you call startService(), the service will run until either you call stopService(), the service calls stopSelf(), or the OS kills off the process to reclaim memory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic