I am trying to get results from native activity in React Native Module. When I called startActivityForResult from my React Native Module, onActivityResult is called immediately even though the activity shows up but RESULT_CANCELED is immediately returned to onActivityResult().
I have followed the official guide from here
My Module code to start activity:
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
    Intent tgIntent = new Intent(currentActivity, SecondActivity.class);
    tgIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
    currentActivity.startActivityForResult(tgIntent, REQUEST_CODE_ENROLLMENT);
}
I tried both of following to set activity event listener but nothing changes
context.addActivityEventListener(activityEventListener);
context.addActivityEventListener(this);
				
                        
Remove the "New Task" flag from the intent.
startActivityForResultmust be under the same task as the calling activity.According to documentation: