Using the built in camera

Monkey Forums/Monkey Beginners/Using the built in camera

blueFire(Posted 2014) [#1]
How would I use monkey to access the built in camera on mobile devices to do something like take a picture?

Jason


Goodlookinguy(Posted 2014) [#2]
At the moment there's no camera module. You'd have to write native platform code to solve this.


blueFire(Posted 2014) [#3]
Any general guidelines on how to import native platform code into monkey?

Jason


Goodlookinguy(Posted 2014) [#4]
I don't really think there are any general guidelines. I just copied what I saw Mark doing in his code.

If you're looking for a tutorial, there is one by Tibit: http://www.monkey-x.com/Community/posts.php?topic=4023


Gerry Quinn(Posted 2014) [#5]
Look at Mark's stuff, or for a less complicated example, look at other modules with native code such as diddy (look at diddy.externfunctions to see how you can simply add native functions).


blueFire(Posted 2014) [#6]
What programming languages can be accessed in this way? In the example he used JavaScript and if I am not mistaken Android uses Java. To use java would I have to compile the external file before I included it or just include the code as a regular file?

Jason


Goodlookinguy(Posted 2014) [#7]
Any programming languages supported can be accessed in that way.

Here are real examples...
Example 1
Glue file.
Native code files

Example 2
Glue File
Native code files

Example 3
Top of this file (glue)
Native code files

Example 4
Near top of this file (glue)
Native file


Tibit(Posted 2014) [#8]
I can strongly recommend that you create a super simple App in the native language, using the native toolset that does what you want it to do and that run on device using debug, and then Wrapping it to Monkey afterwards.

So if you want Camera on Android, create a small Android app that shows the camera (maybe you already have). This means you can have this App to test and fiddle with the Android API if any issue comes up and you can sanity check what it is that is not working, if you get a bugreport in the future.

Up to you of course but when I starting to doing that it saved me a lot of time and energy at least. A lot of the times it wasn't Monkey but my native code that was the cause :)

About using Java or other languages:
Monkey compiles the Java for you after translating your monkey code to java source code - so at the end everything is native code that is compiled using the native toolset to the specific platform.