I am trying to stream data from a laptop to native code in an android phone. Am able to pair with laptop and get data for sometime, but the native code crashes with the following message later:
"failed adding to JNI pinned array ref table".
Code snippet:
// Java code for Bluetooth read handler
case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
// Send the data in the buffer to native code
sendData(readBuf, msg.arg1);
........................................................................
// C-code:
...sendData (JNIEnv *env, jclass cl, jbyteArray arr, jint size)
{
.....
jbyte buffer = (jbyte)env->GetByteArrayElements(arr, &isCopy);
....// copy the buffer to a local variable.
if (isCopy == JNI_TRUE) {
env->ReleaseByteArrayElements(arr, buffer, JNI_ABORT);
}
What could be wrong? I am already using similar code for array transfer between Java and C elsewhere in the code, and that works fine.