Le 02/23/2012 01:44 AM, learner a �crit :
> Hello All,
>
> I am new to JNI and struggling to implement one requirement. I have
> allocated direct buffer in JNI using NewDirectByteBuffer() API and
> want to access the buffer on Java side. But the ByteBuffer.hasArray()
> always returns UnSupportedOperationException.
That's the point with natively allocated direct buffers, the underlying
storage is opaque from Java. You need to use methods like get() and
put() to access the data .
> My requirement: Access the buffer allocated by native in java by not
> copying it.
You might consider using a normal Java array. The third argument of
get<Type>ArrayElements() allows you to determine whether a copy occurs.
In my tests it was always false.
--
Olivier
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Thank you Glenn i will try thi get method suggested by other experts