What is AIDL?
2016-01-27 10:45
435 查看
AIDL我们只知道是用来IPC进程间通信的,但是何时才用到它呢,下面是Android的官方建议!
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. Regardless, be sure that you understand Bound Services before implementing an AIDL.
Calls made from the local process are executed in the same thread that is making the call. If this is your main UI thread, that thread continues to execute in the AIDL interface. If it is another thread, that is the one that executes your code in the service. Thus, if only local threads are accessing the service, you can completely control which threads are executing in it (but if that is the case, then you shouldn’t be using AIDL at all, but should instead create the interface by implementing a Binder).
Calls from a remote process are dispatched from a thread pool the platform maintains inside of your own process. You must be prepared for incoming calls from unknown threads, with multiple calls happening at the same time. In other words, an implementation of an AIDL interface must be completely thread-safe.
The oneway keyword modifies the behavior of remote calls. When used, a remote call does not block; it simply sends the transaction data and immediately returns. The implementation of the interface eventually receives this as a regular call from the Binder thread pool as a normal remote call. If oneway is used with a local call, there is no impact and the call is still synchronous.
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. Regardless, be sure that you understand Bound Services before implementing an AIDL.
Calls made from the local process are executed in the same thread that is making the call. If this is your main UI thread, that thread continues to execute in the AIDL interface. If it is another thread, that is the one that executes your code in the service. Thus, if only local threads are accessing the service, you can completely control which threads are executing in it (but if that is the case, then you shouldn’t be using AIDL at all, but should instead create the interface by implementing a Binder).
Calls from a remote process are dispatched from a thread pool the platform maintains inside of your own process. You must be prepared for incoming calls from unknown threads, with multiple calls happening at the same time. In other words, an implementation of an AIDL interface must be completely thread-safe.
The oneway keyword modifies the behavior of remote calls. When used, a remote call does not block; it simply sends the transaction data and immediately returns. The implementation of the interface eventually receives this as a regular call from the Binder thread pool as a normal remote call. If oneway is used with a local call, there is no impact and the call is still synchronous.
相关文章推荐
- Resolving conflicts between main and test APK
- [lintcode] - 391 Number of Airplanes in the Sky
- 使用Genymotion调试出现错误INSTALL_FAILED_CPU_ABI_INCOMPATI
- TIME_WAIT过多
- http://blog.csdn.net/xyang81/article/details/7292380
- 关于Error: Failed to lookup view "error" in views directory "D:\WebProgram\webBlog\views"的解决方法
- Err http://ppa.launchpad.net trusty/main amd64 Packages 404 Not Found
- HDU 2473 - Junk-Mail Filter ,并查集的删点
- wait和waitpid详解【转】
- linux中waitpid及wait的用法【转】
- 对PyStringObject的认识(Intern机制) http://blog.csdn.net/wangyuquanliuli/article/details/8522302
- django从index访问detail流程
- Ubuntu 14.04 引导修复(Boot Repair)(双系统修复一)
- 自定义dailog注意事项
- Organize Your Train part II-POJ3007模拟
- Organize Your Train part II-POJ3007模拟
- String painter (hdu 2476)
- AI、DI、AO、DO、PI通道代表的意思
- AfxEnableControlContainer()
- RAID简介