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

[Android] Add onUserLeaveHint support to ReactActivityDelegate #43488 #43567

Closed

Conversation

behenate
Copy link
Contributor

Summary:

This PR adds onUserLeaveHint support into the ReactActivityDelegate. It allows modules to receive an event every time user moves the app into the background. This is slightly different than onPause - it's called only when the user intentionally moves the app into the background, e.g. when receiving a call onPause should be called but onUserLeaveHint shouldn't.

This feature is especially useful for libraries implementing features like Picture in Picture (PiP), where using onUserLeaveHint is the recommended way of auto-entering PiP for android < 12.

This is a re-submission of #42741 and #43488 without problematic asserts, which were unnecessary (onUserLeaveHint is not critical to the lifecycle of the app), but were causing problems in some apps.

Changelog:

[ANDROID] [ADDED] - Added onUserLeaveHint support into ReactActivityDelegate

Test Plan:

Tested in the rn-tester app - callbacks are correctly called on both old and new architecture.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Mar 20, 2024
@behenate
Copy link
Contributor Author

@cortinico Do you think we want to keep the log(method); in ReactHostImpl? I have mixed feelings about it, but methods like onHostPause and onHostResume have the log.

@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 18,073,874 -47,920
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,440,618 -46,543
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: ce4d8f2
Branch: main

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 20, 2024
@facebook-github-bot
Copy link
Contributor

@cortinico merged this pull request in 6450d08.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants