Search code examples
androidcandroid-ndkjava-native-interface

Comparing a jbytearray with a string in JNI


I have a JNI C function that has an jbyteArray input parameter. This is a byte array of size 128 that I wish to compare with a #define string. How do I achieve this?

I tried to memcpy the jbyteArray to an unsigned char data[128] and then do a memcmp() of data and the #define, but the memcpy crashed my app.

Thanks.


Solution

  • I ended up copying the jbytearray using GetByteArrayRegion instead.