我正在尝试将一些变量从android native推送到react-native,但是这些文档并没有太大帮助,因为它们非常模糊和过时。我成功地在init上推送了变量,但是我想知道如何使用函数来实现它。
我已经用我自己的类myReactActivityDelegate覆盖了ReactActivityDelegate,该类扩展了ReactActivityDelegate,并添加了我要执行的代码块。
public void updateMsgProps(String prop, String[] messageArray, String[] dateArray){
Bundle updatedProps = mReactRootView.getAppProperties();
updatedProps.putStringArray("messageArray", messageArray);
updatedProps.putStringArray("dateArray", dateArray);
updatedProps.putInt("messageCount", messageArray.length);
mReactRootView.setAppProperties(updatedProps);
};
在我的主要活动中,我有此覆盖:
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new myReactActivityDelegate(this, getMainComponentName()) {
@Nullable
@Override
protected Bundle getLaunchOptions() {
Bundle initialProperties = new Bundle();
//ArrayList<String> imageList = new ArrayList<String>(Arrays.asList(
// "http://foo.com/bar1.png",
// "http://foo.com/bar2.png"
//));
initialProperties.putString("images", "Hallo");
return initialProperties;
}
};
}
如何从本机Java模块访问updateMsgProps?