Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for restore from background (#17) prevent result of ActivityResultRegistry from working correctly #2342

Open
jpcoliveira opened this issue Sep 16, 2024 · 2 comments
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@jpcoliveira
Copy link

jpcoliveira commented Sep 16, 2024

Description

I'm working on a Brownfield project and I need to interact with native contexts. The problem I'm experiencing is the failure to get activity navigation result using ActivityResultRegistry. Setting savedInstanceState to null in onCreate of the Activity Host prevents the result callback from working correctly.

private val launcher = registerForActivityResult(StartActivityForResult()) { result ->
    ...
}

Below, the workaround for avoid crash when restoring from background (#17), this prevent that other behaviors working in moment of restoring.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
}

In my testing, i notice that onActivityResult is invoked, but this method is deprecated and changed for ActivityResultRegistry.

Base on this fact, does react-native-screens have any perspective of fixing this behavior for mitigate impact in projects that needs use ActivityResultRegistry?

Steps to reproduce

  1. Turn on Don't Keep Activities on your device
  2. Open the app
  3. Click on Navigate to MainActivity 2

Result don't works when returning to the MainActivity

Snack or a link to a repository

https://github.com/jpcoliveira/ActivityRegistrySample

Screens version

3.31.1

React Native version

0.71.6

Platforms

Android

JavaScript runtime

V8

Workflow

None

Architecture

None

Build type

None

Device

Real device

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: Android This issue is specific to Android labels Sep 16, 2024
@jpcoliveira
Copy link
Author

@kkafar

@jpcoliveira jpcoliveira changed the title Workaround for restore from background (#17) prevent result of ActivityResultRegistry from working Workaround for restore from background (#17) prevent result of ActivityResultRegistry from working correctly Sep 30, 2024
@kkafar
Copy link
Member

kkafar commented Oct 8, 2024

@jpcoliveira we're aware of this issue, as it happens since #17, thus since the very beginnings of the project. This is on our agenda, however currently there items of higher priority. If you have capacity to suggest / develop a solution, any PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

2 participants