无法在react native中将arraylist传递给本地模块库

时间:2018-06-30 09:32:14

标签: react-native react-native-android native-module react-native-native-module

你好,我想为本机模块调用创建库,所以下面是我的代码

Mylib是我在android中的图书馆项目

package com.reactlibrary;

import java.util.ArrayList;

public class RNMyLibModule extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;

public RNMyLibModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}

@ReactMethod
public void getTags(String qrcode, Callback errCallback, Callback succCallback) throws Throwable {
ArrayList<TagInfo> tagInfos;

tagInfos = parseTag();

try {
    succCallback.invoke(tagInfos);
}catch (IllegalViewOperationException e)
 {
  errCallback.invoke(e.getMessage());
  }
}

@Override
public String getName() {
return "RNMyLib";
  }
}

我从我的js中调用它

MyLib.getTags("call", (msg) => {
  console.log("Error message " + msg)
}, (getTags) => {

  console.log("GET Tags in REact Native: "+getTags)
});

当我运行上述代码时,出现类似“无法连接TagInfo类型的参数”的错误

你知道我该怎么解决吗?您的所有建议都是合理的。

0 个答案:

没有答案