I am working on AOSP11/12(Android) and want to communicate data from java/Kotlin to C++ code or vice versa.
Is that better way to create new service and communicate data or need to create NDK application?
I am working on AOSP11/12(Android) and want to communicate data from java/Kotlin to C++ code or vice versa.
Is that better way to create new service and communicate data or need to create NDK application?
Yes. You need to have a JNI interface to communicate with native solution written in C/C++. The other way is also possible. You can as well call methods of Java class from your C/C++ applications. Primitive data types are copied as it is from Java to native calling and arbitrary data types (objects) are passed as pass by reference mechanism.
This would be a good read to start with: https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/jniTOC.html
While designing an application, please ensure the following: https://developer.android.com/training/articles/perf-jni
Hope this helps!