Using native code in a Monkey program

Monkey Forums/Monkey Beginners/Using native code in a Monkey program

Arabia(Posted 2014) [#1]
I'm sure I've heard you can do this, but for the life of me I can't find information or examples of how to do this. I'm currently compiling for Android, so Java would be most helpful if anyone has information or examples of how to do it.


therevills(Posted 2014) [#2]
Have a search for Extern.

Also have a look at the Diddy source where we use native code via Extern to start the vibrate Android (Java) function:

Monkey code:
http://code.google.com/p/diddy/source/browse/src/diddy/externfunctions.monkey

Android Java Code:
http://code.google.com/p/diddy/source/browse/src/diddy/native/diddy.android.java


Arabia(Posted 2014) [#3]
Thanks very much. I fully expect most of this to go way over my head, but I'll check it out.


Arabia(Posted 2014) [#4]
As expected, it doesn't mean a great deal to me :)

What I was wondering essentially, is that there is plenty of information available on the net and in YT vids showing how to connect to MySQL via Java and the JDBC driver. Would it not be possible to just code this java directly into an app being created for an android device, include the mysql-connector-java-5.x.xx-bin.jar file (in your .data folder I'd assume) and away you go? or am I over simplifying the whole process - I'm sure I am or someone would have possibly knocked this up already in monkey.


golomp(Posted 2014) [#5]
Thank you Therevills, it's exactly what i was needing for my projects.


MikeHart(Posted 2014) [#6]
A good source is also the Admob implementation and other services which Mark has done and which ship with Monkey. The BRL setion in the modules folder.


StoneFaceEXE(Posted 2014) [#7]
I'm not sure what are you talking about, but I think there is a SQL module somewhere.

Probably this one. Will it help or is that driver thing mandatory?
http://www.monkey-x.com/Community/posts.php?topic=5303&post=58834&view=all#58834


Arabia(Posted 2014) [#8]

I'm not sure what are you talking about, but I think there is a SQL module somewhere.

Probably this one. Will it help or is that driver thing mandatory?
http://www.monkey-x.com/Community/posts.php?topic=5303&post=58834&view=all#58834



This is actually a mini implementation of SQL with the data being held within the SaveState file on the device, which is useful for apps which need to store & retrieve data locally only. I'm sure it could be modified easily enough to access a text file on the Internet, but not really suited to larger scale or even multi-user databases as far as I can tell.

I've done a little bit more digging around, the Admob stuff that Mike suggested actually makes a bit more sense to me when looking at it over Diddy, and Admob does make use of a .jar file as would be required with a MySQL module - so that is a starting point at least.

It would appear from what I've read that MySQL is fully supported in Android (as of 2.3 I believe?) in terms of a driver being available. A lot of misinformation I found suggested it wasn't available, but they were referring to running an Android device as the MySQL server from what I've read.

One question which maybe someone more knowledgeable can answer : how secure are the Android Apps - or iOS or XNA for that matter? The code itself is going to have to have the database username and password coded into it to connect to the database, how easy/hard would it be for someone to hack the app and get this information? If it's at all possible then that would create a real security issue.


golomp(Posted 2014) [#9]
Android Apps (and probably iOS too) are not secured at all. It's relatively easy to modify one and change graphism, constante values, names and so on.

If you want a better secured app you do server connection, record and check the user rights to access your product (time, number of connection, name,IP, mac address) with a crypted matrix.
Two case :
1) If server's check is ok, server send a "answer crypted matrix" with values to uncrypt sensible datas and affect execution vector points.
2) If server's check is not ok, you send a "special corrupted matrix" wich indicate your app to close. (use normal end point without special message)

On your server you program a robot to check regulary the connections data, eventually blacklist connection (still without any message for user) and send you a SMS to inform you.