Note that there are some explanatory texts on larger screens.

plurals
  1. POJNI: From C code to Java and JNI
    text
    copied!<h3>Background</h3> <p>I am developing an application for android in eclipse and now I have a problem and I need your help. So I must Call function written in <strong><em>C</em></strong> from JAVA application. But on my way of writing code I have some <strong><em>Questions</em></strong> which you can see below. I am waiting for your answers and ideas ... </p> <h3>C Code:</h3> <pre><code>typdef struct blobData_s { unsigned long length; unsigned char data[1]; } blobData_t; unsigned int CheckEnrollmentExist ( unsigned long hdevice, blobData_t* pInputInfo ) { // Function code goes here .......................... return some_value; } </code></pre> <hr> <h3>JAVA Code:</h3> <p>In JAVA code instead of <code>unsigned long</code> I use <code>int</code> so I can write. </p> <pre><code>class jblobData_c { public int langth; *Question 1.* } public class ApplicationMainClass extends Activity { // Some code goes here ...................... public native int JCheckEnrollmentExist( int jhdevive, *Question 2.* ); } </code></pre> <p><strong><em>Question 1.</em></strong></p> <ul> <li>What I can use instead of <code>unsigned char</code> in JAVA Code ?</li> <li>What I must write in JAVA code instead of <code>unsigned char data[1];</code> ?</li> </ul> <p><strong><em>Question 2.</em></strong></p> <ul> <li>How I can use <code>class jblobData_c</code> instead of <code>blobData_t* pInputInfo</code> in the JAVA Code ?</li> <li>What I must write in JAVA instead of <code>blobData_t* pInputInfo</code> ?</li> </ul> <hr> <h3>JNI Code:</h3> <pre><code>JNIEXPORT jint JNICALL Java_com_Test_JCheckEnrollmentExist(JNIEnv* env, jobject obj, jint jhdevice, *Question 2.* ) { // Call the base function from C code. return CheckEnrollmentExist( jhdevice, *Question 3.*); } </code></pre> <p><strong><em>Question 3.</em></strong></p> <ul> <li>What I must write in <code>CheckEnrollmentExist</code> function that is C Code Function instead of <code>blobData_t* pInputInfo</code> in order this function works right and given parameter be the same </li> </ul> <h3>Reference</h3> <ol> <li><a href="https://stackoverflow.com/questions/3923299/how-to-pass-c-structs-back-and-forth-to-java-code-in-jni"><strong><em>How to pass C structs back and forth to Java code in JNI ?</em></strong></a></li> <li><a href="https://stackoverflow.com/questions/1571175/passing-large-c-structure-through-jni-efficiently"><strong><em>Passing large C structure through JNI efficiently</em></strong></a></li> <li><a href="http://www.coderanch.com/t/274504/java/java/Return-Structure-Object-Java-Through" rel="nofollow noreferrer"><strong><em>Return a Structure Object from C to Java Through JNI</em></strong></a></li> <li><a href="https://stackoverflow.com/questions/4324819/pass-data-between-java-and-c/4325678#4325678"><strong><em>Pass data between Java and C</em></strong></a></li> <li><a href="https://stackoverflow.com/questions/5802340/passing-a-pointer-from-jni-to-java-using-a-long"><strong><em>Passing a pointer from JNI to Java using a long</em></strong></a></li> <li><a href="https://stackoverflow.com/questions/1632367/passing-pointers-between-c-and-java-through-jni"><strong><em>Passing pointers between C and Java through JNI</em></strong></a></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload