接收应用程序到应用程序的响应,但将被调用的应用程序没有自己的意图

Receive app-to-app response, but app that will be called has no intent of its own

在此先感谢您的帮助,我需要为 react-native 制作一个模块,以获取深度链接打开应用程序并获取应用程序 'data' 的 return [=26] =]ed,但我是 react-native 的新手,这涉及 java(使用 android)查看模块代码 react-native-activity-result。 我的测试示例代码尝试执行模块

Codigo do módulo react-native-activity-result

  @ReactMethod
  public void startActivityForResult(int requestCode, String action, ReadableMap data, Promise promise) {
      Activity activity = getReactApplicationContext().getCurrentActivity();
      Intent intent = new Intent(action);
      intent.putExtras(Arguments.toBundle(data));
      activity.startActivityForResult(intent, requestCode);
      mPromises.put(requestCode, promise);
}

需要deeplink打开的应用代码

Private final int REQUEST_CODE = 1001;
protected void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Bundle bundle = new Bundle();
  bundle.putString("amount","0000000000100");
  bundle.putString("currencyPosition","CURRENCY_AFTER_AMOUNT");
  bundle.putString("currencyCode","986");
  Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("getnet://pagamento/v1/payment"));
  intent.putExtras(bundle);
  startActivityForResult(intent,REQUEST_CODE)
}

我尝试执行模块的测试示例代码

  @ReactMethod
  public void startActivityForResultUnintentionally(int requestCode, String deepLink, ReadableMap data, Promise promise) {
      Activity activity = getReactApplicationContext().getCurrentActivity();
      Intent intent = new Intent(ACTION_VIEW,Uri.parse(deepLink));
      intent.putExtras(Arguments.toBundle(data));
      activity.startActivityForResultUnintentionally(intent, requestCode);
      mPromises.put(requestCode, promise);

我得到 1 我采用了 action 参数并在适当的位置添加了一个 deepLink 参数,然后在 action 参数有意义的地方我放置了 ACTION.VIEW,另一个参数添加了从 String 转换为 Uri 的 Deeplink。

@ReactMethod
    public void startActivityForResult(int requestCode, String deeplink, ReadableMap data, Promise promise) {
        Activity activity = getReactApplicationContext().getCurrentActivity();
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deeplink));
        intent.putExtras(Arguments.toBundle(data));
        activity.startActivityForResult(intent, requestCode);
        mPromises.put(requestCode, promise);
    }