Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use an aidl based service?

Tags:

android

aidl

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)?

like image 512
MalcomTucker Avatar asked Jul 26 '10 13:07

MalcomTucker


People also ask

Where is AIDL used?

AIDL can be used between any process in Android: between platform components or between apps. However, it is never used as an API for apps. AIDL may be used to implement an SDK API in the platform, for instance, but the SDK API surface never contains AIDL APIs directly.

Why is AIDL used?

The Android Interface Definition Language (AIDL) is similar to other IDLs you might have worked with. It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

What is AIDL service?

AIDL (Android Interface Definition Language) is similar to other IDLs. It allows us to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

What is the difference between using Messenger and AIDL?

This technique allows you to perform interprocess communication (IPC) without the need to use AIDL. Using a Messenger for your interface is simpler than using AIDL because Messenger queues all calls to the service. A pure AIDL interface sends simultaneous requests to the service, which must then handle multi-threading.


2 Answers

1.when to use aidl based service.

A few benefits can be gained by segment part of your code into backend service:

  • decouple front-end and back-end
  • memory/cpu intensive processing can be stacked to backend service, GC in service will not affect front-end user experience
  • service crash will not bring down the whole APP

2.how to create such a service

I have written a good library, you can refer as an example http://github.com/zhchang/hogwarts

like image 147
zhao chang Avatar answered Oct 07 '22 18:10

zhao chang


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.

like image 41
Erich Douglass Avatar answered Oct 07 '22 16:10

Erich Douglass