tags:

views:

89

answers:

2

Under what circumstances would using AIDL to define a service interface be the correct decision (rather than just creating an extension to the service class)?

+1  A: 

Merely extending a service class will not allow your service to expose its methods to outside entities. If you want your service to be exposed/used by code which runs out of your android app, you will have to define an AIDL for it. This AIDL will be shared and be formed as contract for your service. Refer this http://developer.android.com/guide/developing/tools/aidl.html.

Tushar Tarkas
But assuming only your app makes use of the service, there is no reason to use aidl - is that correct?
MalcomTucker
Correct. But then why would you like to create a service in that case either.
Tushar Tarkas
I created a local service in my app to do a bigger download. In that way I could have some more control and security then just an Async Task that can be killed all every time. As I understand a service that is bound to an activity is not that likely to be killed if resources are scarce.
Janusz
A: 

You need to use AIDL if you want a class outside of your application's process to access the Service. If you're only using the service from inside your application, you can use a local service.

Erich Douglass