Tom Dawn Tom Dawn - 25 days ago 18
Android Question

Android project change part of Java code into C++

I have a complete Android project, its working well. However, I want to change part of the java code into C++, is that possible? For example, I have one particular function like

protected long convert64to32 (long long_id) {
return long_id - 76561197960265728L;
}


While keeping the rest of my code the same as before, I only want to change convert64to32 into a C++ function, and keeping the connection with the rest Java code, is that possible?

Answer

There generally is support for native C/C++ in Android (and AndroidStudio IDE) through the Android NDK API.

But it requires more than just declaring a method to be written in native language. Basically you need to create a native library and link it to your Android Project.

Comments