4

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?

Paul Ratazzi
  • 5,881
  • 3
  • 33
  • 48
Midson
  • 968
  • 3
  • 11
  • 22

2 Answers2

5

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

You can also download the android source code and look into frameworks/base/camera/tests/CameraServiceTest/CameraServiceTest.cpp

Cheers!

thejh
  • 41,293
  • 15
  • 89
  • 105
  • Thanks Sam. I have gone thru the some of the native services. But the complexity of thous services blocking the basic understanding of the binder concept. I hope, this example will help me understand binder :) – Midson Oct 28 '10 at 01:57
  • Are you able to successfully compile this code? – Midson Oct 30 '10 at 08:15
  • Thanks Sam, Wonder example for understanding abt android binder. I downlaoded the sample and i build with the android source code placed HelloWorldService under packages/app and i genereted the apk and so files. But SERVICe is not created.... getting following logs : > ERROR/HelloWorld(491): services :::::: [Ljava.lang.String;@4051b358 > ERROR/HelloWorld(491): services LENGTH is 5 ERROR/HelloWorld(491): > services isMyServiceRunning ::: false ERROR/HelloWorld(491): > services[0]=null ERROR/HelloWorld(491): services[1]=null > ERROR/HelloWorld(491): services[2]=null ERROR/HelloWorld(491): > serv – Ganesh Ramamoorthy Oct 18 '11 at 12:46
2

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.

Thanks for this simple example illustrating binder use.

KurtCobain
  • 591
  • 1
  • 5
  • 15