title: How to invoke specific Java method from NDK(JNI)?
body: <p>I am fresh in this topic.</p>
  
  <p>I use NDK in my Android app and I have such method in Java</p>
  
  <pre><code>static byte[] getBytes(Bitmap bitmap)
  {
      int size = bitmap.getRowBytes() * bitmap.getHeight();
      ByteBuffer byteBuffer = ByteBuffer.allocate(size);
      bitmap.copyPixelsToBuffer(byteBuffer);
      return byteBuffer.array();
  }
  </code></pre>
  
  <p>Now I need to use this method from NDK</p>
  
  <p>Actually I wrote something like this </p>
  
  <pre><code>jbyteArray arr = env-&gt;CallStaticByteMethod(jniIds.helper_class, jniIds.get_bytes, image_obj);
  </code></pre>
  
  <p>But problem is <code>CallStaticByteMethod</code> return type <code>jbyte</code>, but I need <code>jbyteArray</code>...</p>
  
  <p>So, question how to write this method?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>jobject arr_obj = env-&gt;CallStaticObjectMethod(jniIds.helper_class, jniIds.get_bytes, image_obj);
  jbyteArray arr = static_cast&lt;jbyteArray&gt;(arr_obj);
  
  //my needed result
  unsigned char myArr = reinterpret_cast&lt;unsigned char&gt;(arr);
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>jbyteArray arr_obj = (jbyteArray) env-&gt;CallStaticObjectMethod(jniIds.helper_class, jniIds.get_bytes, image_obj);
  </code></pre>
  
  <p>Now I have jbyteArray... but anyway I don't understand how with using of <code>GetByteArrayElements</code> get my <code>byte[]</code> into my var <code>unsigned char *i_image</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>jbyteArray arr_obj = (jbyteArray)env-&gt;CallStaticObjectMethod(jniIds.helper_class, jniIds.get_bytes, image_obj);
  jbyte *b = (jbyte *) env-&gt;GetByteArrayElements(arr_obj, NULL);
  i_image = reinterpret_cast&lt;unsigned char *&gt;(b);
  env-&gt;ReleaseByteArrayElements(arr_obj, b, JNI_ABORT);
  </code></pre>