How To Use Generated Matlab Code in Android? - android

I have generated MATLAB code than contains a lot of C codes and C/C++ headers.I don't know how to use this code with NDK in Android.
1-Should I change c codes for use in Android?
2-How to use this codes in Android Project?
3-Is there any tutorial or book to use generated code in Android Project?

The android can interact with c/c++ code using JNI. Here are some links which may help you understand the Interaction between Native Code and Android Java Language.
Using C and C++ Code in an Android App with the NDK
Add native code to android
and so on...

Related

How to call a C function from a react-native code?

I have developed a small android application using react-native. For what it was developed, it works fine. Now to accommodate a small requirement, we need to call a library written in C. I am not sure if there will be a way to call the C code from JavaScript! But I still wanted to ask you all.
Is there a way to do this from react-native? Like I want to call some functions in the C library. If this possible, could you please suggest how? How could I start to test a very basic setup?
You are going to have to write some native code, search for how to call a C lib on Android, then look for react native way to link a native code with a js call.
Native Module link https://facebook.github.io/react-native/docs/native-modules-android.html
StackOverflow question on how to run c/cpp code on android how to use c/cpp library/functions in android
Basically it includes 3 parts.
JavaScript to Java or Kotlin
check out React Native's guide to Android Native Module.
Java or Kotlin to C
Calling C functions from Java is enabled with a mechanism called Java Native Interface (JNI) . check out how to add C and C++ code here.
see more here https://thebhwgroup.com/blog/react-native-jni

Can we use Vuforia with NativeActivity on Android

All the samples from Vuforia official website use pure Java or Java together with c++. But, my application uses only NativeActivity, in other word, it contains no java code. The question is can I use Vuforia in an application which has only c++ code?
NativeActivity is just a Java file provided by the framework: https://android.googlesource.com/platform/frameworks/base.git/+/master/core/java/android/app/NativeActivity.java
Any Android app will need to handle the Android Activity Lifecycle and in your case it will need to wrap any C/C++ code you may have.

Is it possible to use a C library in background service for an android app?

I have a library written in C which I want to use in an android application. Is it possible to use this library in background service for the app? Can NDK be used for this? Or is there any other method available?
If you are a fresher in JNI with Android , try to learn some basics like HelloWorld programs .
You will get JNI example 1 , example 2 .
You need to setup Android NDK to compile all of your native codes

Difference between writing OpenCV for Android(Mobile devices) and writing openCV for Desktop Application(OpenCV 2.4.3 usingC++)

I was doing face detection and recognition project.I am about to finish the application which does detection and recognition. I want to make this application portable like a one that works on Mobile devices. I am new to writing codes using OpenCV on Androids. What is the difference between OpenCV codes for Android phones and OpenCV written for Desktop application using C++ on Visual Studio like VS 2010 with Open CV 2.4.3?(What is the difference between Codes between OpenCV on Android and OpenCV for Desktop.Do they both use the same language?)
I am familiar with Android(basics) and true that Android applications are written with Java. And i read somewhere online that OpenCV native codes can be included to Android with Java Native Interface.
I am a bit confused here that can i use the code i have written using C++ Open CV for my Android Application with out modification.If not what Kind of modification do i have to make on my face detection and recognition using C++ for Desktop to make it work for Android phones?
First off, there exists an OpenCV4Android version of Android, with tutorials on how to use it.
Then, as you pointed out, you can code both in Java or C++ on Android. OpenCV4Android can be used in Java [1] or in C++ [2]. In your case, it would probably be more convenient to re-use your C++ code, using the Native Development Kit for Android. If you manage to use the NDK, you will be able to re-use your C++ code by calling it from your Android app.
Here are the few steps I would advise you to follow:
Read about the Native Development Kit
Read about the Java Native Interface
Try to create a sample Android app using C++ (You might find this quickstart tutorial useful)
Try to integrate OpenCV to your sample [2]
Include your existing C++ code in your sample
I hope it will help.
I used OpenCV on Android using both Java and C++. From my experience, I can suggest to use Native C++ code for image processing application. C++ codes are more efficient and can give more identical result as compared to Java code.
Although OpenCV has the Java version also, but in the back-end, it is using Native code for running Java.
The speed of execution in Native code will be much high as compared to Java code.

Connecting a C library to iOS app

I hope there is somebody that can help me with the following.
Currently i have an Android app that is connected to a C library using JNI.
Now i would like to connect my iOS app to that same C library, but how can i call the functions and how can i access the interfaces without JNI?
Hopefully somebody has some good tips or tutorials.
So what i have is an Android App, an iOS App and a C-library adapted to JNI (Java Native Interface). The Android part works. But now i would like to reuse as much as possible but still connect my iOS app to that (or most of that) library. (library are separate header and .c files)
Please help :)
To elaborate slightly on my comment - unlike Android, iOS apps are built using Objective C with Apple's libraries. Objective C is a superset of C, which means that any valid C code is also valid Objective C code. You should be able to add the source files directly to an iOS project in Xcode, and sprinkle library calls anywhere you want. That means there is nothing like the JNI for iOS (or OSX) development.
You have two options:
Directly use your library by adding it to project in xcode, assign a library search path, assign header search path and incude headers in .m objective-c source code that use it.
Add all .c files to be compiled and linked by xcode and incude headers in .m objective-c source code that use it.
p.s. if you have used some particular compiler switches you may need to rebuild your libraries to properly target iOS.

Categories

Resources