JuiCe
JuiCe

Reputation: 4201

Converting a project from C to Java

I am currently messing around with Android beginning to make an app. The application connects with a bluetooth device, then sends it signals, then the other device sends back the data that was requested.

I was given documentation for the other devices API written in C, which basically stores all the specific signals needed to send the device. How can I change these from C files to java files. I have downloaded the Android NDK but don't know what to do with it. Any help would be appreciated.

Upvotes: 0

Views: 152

Answers (1)

Orlymee
Orlymee

Reputation: 2357

You can call the C library from your Android Java code, (if i understood you correctly this is what you wanted to do). You will need NDK and will need to use JNI to allow the java code to talk to the c library. There are plenty of good tutorials on these just search.

For example Marakana has a good tutorial/video on Android internals. Take a look at the part where he talks about building applications with JNI support. He uses example of a library in C that calculates fibonacci sequence but he calls that library from Java.

Upvotes: 1

Related Questions