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] onRequestPermissionsResult prevents registerForActivityResult callback #42403

Closed
LimAlbert opened this issue Jan 19, 2024 · 1 comment
Labels
Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged.

Comments

@LimAlbert
Copy link
Contributor

LimAlbert commented Jan 19, 2024

Description

Hello,

I'm currently trying to implement health connect on Android 14 but I've found out that registerForActivityResult is never calling its callback since onRequestPermissionsResult

Is there a reason why

@Override
   public void onRequestPermissionsResult(
       int requestCode, String[] permissions, int[] grantResults) { 
     mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
   }

doesn't call super.onRequestPermissionsResult(requestCode, permissions, grantResults); ?

After adding it to onRequestPermissionsResult, everything works as expected.

I've tried creating a patch adding this line and everything works as intended (https://github.com/LimAlbert/react-native-health-connect-android14)

Steps to reproduce

  1. yarn
  2. Launch Android studio
  3. Open project
  4. Open logcat
  5. Filter using "REPRO_PERMISSION"
  6. Run App
  7. Accept All permissions
  8. Witness that HAS CALLED CALLBACK is never logged

React Native Version

0.73.2

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 170.23 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.12.1
    path: ~/.asdf/installs/nodejs/18.12.1/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.asdf/installs/nodejs/18.12.1/bin/yarn
  npm:
    version: 8.19.2
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 2023.11.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.13.0
    path: /Users/alim/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11255304
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 17
    path: /Users/alim/.asdf/shims/javac
  Ruby:
    version: 3.2.2
    path: /Users/alim/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

2024-01-19 21:43:14.409  8656-8656  REPRO_PERMISSION       com.reproonrequestpermissionsresult  D  CALLING LAUNCH

Reproducer

https://github.com/LimAlbert/reproonrequestpermissionsresult

Screenshots and Videos

No response

@cortinico
Copy link
Contributor

doesn't call super.onRequestPermissionsResult(requestCode, permissions, grantResults); ?

Nope there is no particular reason. Thanks for sending over #42478
I'll look into it.

@cortinico cortinico added Resolution: Fixed A PR that fixes this issue has been merged. and removed Needs: Triage 🔍 labels Jan 22, 2024
blakef pushed a commit that referenced this issue Jan 25, 2024
Summary:
This change allows activities to handle onRequestPermissionsResult callbacks (eg: registerForActivityResult)

Fixes #42403

[Android][Changed] - Call super.onRequestPermissionsResult in ReactActivity's onRequestPermissionsResult()

Pull Request resolved: #42478

Test Plan:
**Without super.onRequestPermissionsResult() call**

![before](https://github.com/facebook/react-native/assets/8672580/553ff597-c077-4831-a4d3-51846a253536)

**With super.onRequestPermissionsResult() call**

![after](https://github.com/facebook/react-native/assets/8672580/c7d588d2-5846-4083-a02f-59b5f915442c)

Reviewed By: cipolleschi

Differential Revision: D52952198

Pulled By: cortinico

fbshipit-source-id: 53b5dac65f6b5409d87b5fe7f8be659d7b48f70d
lunaleaps pushed a commit that referenced this issue Feb 16, 2024
Summary:
This change allows activities to handle onRequestPermissionsResult callbacks (eg: registerForActivityResult)

Fixes #42403

[Android][Changed] - Call super.onRequestPermissionsResult in ReactActivity's onRequestPermissionsResult()

Pull Request resolved: #42478

Test Plan:
**Without super.onRequestPermissionsResult() call**

![before](https://github.com/facebook/react-native/assets/8672580/553ff597-c077-4831-a4d3-51846a253536)

**With super.onRequestPermissionsResult() call**

![after](https://github.com/facebook/react-native/assets/8672580/c7d588d2-5846-4083-a02f-59b5f915442c)

Reviewed By: cipolleschi

Differential Revision: D52952198

Pulled By: cortinico

fbshipit-source-id: 53b5dac65f6b5409d87b5fe7f8be659d7b48f70d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

No branches or pull requests

2 participants