【问题标题】:FLAG_ACTIVITY_NEW_TASK error integrating android native library in react nativeFLAG_ACTIVITY_NEW_TASK 错误将 android 本机库集成到反应本机中
【发布时间】:2019-12-12 00:37:13
【问题描述】:

我正在尝试将原生支付库集成到 react 原生应用程序中。

图书馆需要这样的视图设置来处理支付结果。

库引发下一个错误

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

不知道是不是我的配置错误,原生库演示应用运行正常。 :( 支付响应意图尝试加载活动,但显然找不到它。

更新
失败的库函数是:

String appId = context.getPackageName() + "." + callbackSchema;
Intent intent = new Intent(appId);
intent.putExtra(ConstantUtil.RETURNED_JSON_KEY,json);
context.startActivity(intent); // <- this call raises the error

更新 最后我让它工作了。我是这样传递上下文的:

getReactApplicationContext()

我通过这样的上下文解决了它:

getCurrentActivity()

在调试中,我得到了这个值:

但错误仍在提高:(

有什么想法吗?

【问题讨论】:

    标签: java android react-native android-intent


    【解决方案1】:

    最后我成功了。我是这样传递上下文的:

    getReactApplicationContext()
    

    我通过这样的上下文解决了它:

    getCurrentActivity()
    

    【讨论】:

      猜你喜欢
      • 2015-12-23
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多