Android 活页夹示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3573266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Binder Example
提问by Midson
I am looking for simple binder IPC example in C/C++. Recently I started reading about the Android Binder basic (http://bharathi.posterous.com/android-binder) and gone thru the code in Android source also. Most of the binder usage part is in C++. Can some one explain why C++ is used instead of C?
我正在寻找 C/C++ 中的简单活页夹 IPC 示例。最近我开始阅读 Android Binder basic ( http://bharathi.posterous.com/android-binder) 并阅读了 Android 源代码中的代码。大多数binder使用部分是在C++中。有人可以解释为什么使用 C++ 而不是 C 吗?
回答by Samuel Sk?nberg
Check out http://github.com/mcr/Android-HelloWorldService(if you use later versions of android you may have to exchange some includes from #include <utils/something>
to #include <binder/something>
).
查看http://github.com/mcr/Android-HelloWorldService(如果您使用更高版本的 android,您可能需要从#include <utils/something>
到交换一些包含#include <binder/something>
)。
You can also download the android source code and look into frameworks/base/camera/tests/CameraServiceTest/CameraServiceTest.cpp
您还可以下载 android 源代码并查看 frameworks/base/camera/tests/CameraServiceTest/CameraServiceTest.cpp
Cheers!
干杯!
回答by KurtCobain
I was able to get the native application compile and working on Android 2.3 source code. For this I had to make two changes - 1st is change the path of binder include files from to and secondly to include the libbinder in the libhelloworldservice makefile.
我能够编译本机应用程序并在 Android 2.3 源代码上工作。为此,我必须进行两项更改 - 第一个是将绑定器包含文件的路径从 to 更改为,第二个是将 libbinder 包含在 libhelloworldservice makefile 中。
Thanks for this simple example illustrating binder use.
感谢这个简单的例子说明了活页夹的使用。