如何从React Native打开Android活动

时间:2018-08-06 12:54:03

标签: android react-native react-redux react-native-android

我想从图中所示的空白处的react native打开android native模块

image

但是它正在打开一个新活动,而不是显示在同一活动上。

这是我的反应本机代码

MyNativeModule.nativeModule(data);

下面是我的MyNativeModule.java

public class MyNativeModule extends ReactContextBaseJavaModule {
    public MyNativeModule(ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @ReactMethod
    public void nativeModule(String token){
        Intent intent = new Intent(getReactApplicationContext(),MainActivity.class);
        intent.putExtra("data", data.toString());
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        getReactApplicationContext().startActivity(intent);
    }

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

0 个答案:

没有答案