1

I'm currently stuck trying to convert a Java.Nio.ByteBuffer to an array or a string in a Xamarin Android App.

byte[] outputBytes = new byte[16];
Java.Nio.Buffer outputBuffer = ByteBuffer.Wrap(outputBytes);
//... filling buffer (using tflite model)
byte[] bufferBytes = ???

How can I get the content of the buffer?

Apparently there is a function like buffer.array(), but it doesn't work here.

So if anyone has an idea how i can make this work or any other way, help would be really appreciated.

8
  • possible duplicate of stackoverflow.com/q/17354891 or stackoverflow.com/q/1252468 Commented Jan 27, 2020 at 16:20
  • Not a duplicate. Suggestions in first link don't work due to working in another environment (I guess), which is exactly the problem here. Commented Jan 27, 2020 at 16:25
  • Second one too, I'm not writing plain java code, I can't access the methods mentioned. Commented Jan 27, 2020 at 16:27
  • what about stackoverflow.com/q/43117553 or forums.xamarin.com/discussion/28763/…? Commented Jan 27, 2020 at 16:30
  • The first one actually looks like it might help, but I'm getting this with every method I tried: Error CS1061 "Buffer" does not contain a definition for "GetFloat", and no accessible GetFloat extension method that accepts a first argument of type "Buffer" could be found (a using directive or assembly reference may be missing). Commented Jan 27, 2020 at 16:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.