2

I'm working on a mobile app with React Native.

I have a native java function which receive an int array as argument:

@ReactMethod
public void createImage(int[] pixels, int width, int height, Callback callback) {
    Integer eventId = 10;
    Bitmap bmp = getBitmap(pixels, width, height);
    String res = convert(bmp);
    callback.invoke(res);
}

I call this function from my react native code like this:

var array = [];
for(let i = 0; i < 256*256; i++)
{
    array.push(i%256);
}

CalendarModule.createCalendarEvent(
    array,
    256,
    256,
    (res) => {
      console.log(`Result ${res}`);
    }
);

But I have the following error as result:

Got unknown argument class: int[]

A also try with java list<Integer> but it's also doesn't work.

Is it possible to pass a javascript list to a java function with a list argument ?

1 Answer 1

3

It could be because int[] is not a supported argument type for native module methods: https://reactnative.dev/docs/native-modules-android#argument-types

Sign up to request clarification or add additional context in comments.

Comments

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.