facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.52k stars 24.37k forks source link

BackHandler Does Not Work Google Pixel #44670

Open enchorb opened 6 months ago

enchorb commented 6 months ago

Description

More detail: https://github.com/react-navigation/react-navigation/issues/11227

It seems on Google Pixel devices the BackHandler does not work

Steps to reproduce

Use back handler on Google Pixel 6+ device

React Native Version

0.74

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: Windows 10 10.0.19045
  CPU: (20) x64 Intel(R) Core(TM) i9-10850K CPU @ 3.60GHz
  Memory: 64.71 GB / 127.92 GB
Binaries:
  Node:
    version: 20.13.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 4.2.1
    path: C:\Program Files\nodejs\yarn.CMD
  npm:
    version: 10.5.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "29"
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-29 | Google Play Intel x86 Atom
      - android-30 | Google Play Intel x86 Atom
      - android-31 | Google Play Intel x86_64 Atom
      - android-33 | Google Play Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
  Windows SDK:
    AllowAllTrustedApps: Enabled
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.17763.0
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java: 17.0.11
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.73.8
    wanted: 0.73.8
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

N/A

Reproducer

https://github.com/Roamer77/Android13backButtonBug

Screenshots and Videos

No response

github-actions[bot] commented 6 months ago
:warning: Add or Reformat Version Info
:information_source: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
github-actions[bot] commented 6 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
cortinico commented 5 months ago

It seems on Google Pixel devices the BackHandler does not work

A couple of questions:

  1. Can you clarify what you mean with "BackHandler" here?
  2. Can you point to the code in your reproducer where you're managing the back gesture?
  3. Can you provide a video of the currect/expected behavior.

Please answer all of them and we'll be able to investigate further

github-actions[bot] commented 5 months ago

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

enchorb commented 4 months ago

@cortinico To answer your questions:

  1. By BackHandler, I'm referring to handling the Android back button. When using React Navigation on non-Pixel devices, when the hardware back button is pressed it navigates to the previous screen. On Pixel devices it just closes the app.

  2. https://github.com/Roamer77/Android13backButtonBug (to test you can you the Android emulator or actual device). Any Pixel version works, I tested on Pixel 7 Pro API 34 & Pixel 6.

  3. Not shown in the video, on the Android emulator pressed the hardware back button

    Screen_recording_20240704_101748.webm

ImBeCiliC commented 3 months ago

@cortinico To answer your questions:

  1. By BackHandler, I'm referring to handling the Android back button. When using React Navigation on non-Pixel devices, when the hardware back button is pressed it navigates to the previous screen. On Pixel devices it just closes the app.
  2. https://github.com/Roamer77/Android13backButtonBug (to test you can you the Android emulator or actual device). Any Pixel version works, I tested on Pixel 7 Pro API 34 & Pixel 6.
  3. Not shown in the video, on the Android emulator pressed the hardware back button

    Screen_recording_20240704_101748.webm

I double checked on other devices. The same is happening on my app. It just closes the app and is not only tight to pixel devices. It is the android version operating it. In my case i used android version 14 to test. On Api 29 it still works so its a mix of android change and react native update.

usmanabid94 commented 1 month ago

I have used the backhandler on my device pixel 5 and face this issue still. @ImBeCiliC