Search code examples
androidarchitectureandroid-sensors

How to play with devices like accelerometer and camera using C/C++?


As you can see in architecture diagram below android platform has been built using different layers.

  • Application are developed in Java
  • Application Framework is written using Java (according to my understanding)
  • Libraries are in C/C++

enter image description here

For some insane reason I have to play/deal with devices like accelerometer, compass and camera using C/C++ which means directly accessing them in 3rd layer i.e. Libraries. According to my understanding the Application Framework itself would be consuming Libraries for accessing these devices and then providing APIs for Applications.

I am looking for any documentation/tutorials/demo which can help me in this regard i.e how to access and use these devices like camera, accelerometer and compass from C/C++ code or in other words how to play with these devices directly from Libraries layer.

My last option would be to get the android source code and dig deep into it to find out what I am looking for but I would like some easy way in form of a documentation/demo/tutorial/anything that can make this a bit easy for me.


Solution

  • I am looking for any documentation/tutorials/demo which can help me in this regard i.e how to access and use these devices like camera, accelerometer and compass from C/C++ code or in other words how to play with these devices directly from Libraries layer.

    You don't. You access them from Java code. Reorganize your C/C++ code to support your Java code.