标签:android aidl remote service
关于remote service中使用aidl来实现跨进程,多线程通信,我是参考了三篇文章,大概把这个弄明白了。
(1)android 官方关于aidl的说明文档
docs/guide/components/aidl.html
(2)Android学习笔记23服务Service之AIDL和远程服务实现进程通信以及进程间传递自定义类型参数
http://blog.csdn.net/honeybaby201314/article/details/19989455
(3) Android AIDL使用详解
http://blog.csdn.net/stonecao/article/details/6425019
AIDL (Android Interface Definition Language) 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).
AIDL(android接口定义语言)与IDLs类似,他主要是定义客户端与服务器统一的编程接口以便让客户端与服务器端跨进程通信(IPC)。
Note: Using AIDL is necessary only if you allow clients from different applications to access your service for IPC and want to handle multithreading in your service. If you do not need to perform concurrent IPC across different applications, you should create your interface by implementing a Binder or, if you want to perform IPC, but do not need to handle multithreading, implement your interface using a Messenger.
如果clients要从不同应用跨进程访问service,在service中处理多线程操作。我们才会使用AIDL。如果不需要跨进程,我们可以创建实现Binder的接口,如果我们需要跨进程通信,但是不需要处理多线程操作,那么,我们可以使用Messager.
To create a bounded service using AIDL, follow these steps:
This file defines the programming interface with method signatures.
The Android SDK tools generate an interface in the Java programming language, based on your .aidl file. This interface has an inner abstract class named Stub that extends Binder and implements methods from your AIDL interface. You must extend the Stub class and implement the methods.
Implement a Service and override onBind() to return your implementation of the Stub class.
我以官方文档和另外一个样例,写了一个Demo来说明如何实现aidl的使用。
(1)客户端
(2)服务端
版权声明:本文为博主原创文章,未经博主允许不得转载。
android学习之remote service 的aidl详解
标签:android aidl remote service
原文地址:http://blog.csdn.net/hfreeman2008/article/details/47431123