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)?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
1.when to use aidl based service.
A few benefits can be gained by segment part of your code into backend service:
2.how to create such a service
I have written a good library, you can refer as an example http://github.com/zhchang/hogwarts
AIDL
The Android Interface Definition Language (AIDL) allows developers to define a programming interface that the client and server use to communicate with each other using Inter-Process Communication (IPC).
This article shows how to connect to a running service in Android, and how to retrieve the data from the remote/running service.
Example of IPC mechanism
Let RemoteService be a client service and RemoteServiceClient be an Activity to communicate with the remote service.
One service provides information about the mathematic operations like addition, subtraction, and multiplication for the given two integers. To expose the functionality of what Service can do, create an .aidl file in the project directory.
AIDL Example
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.
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/components/aidl.html.