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] AppState 'inactive' not triggered on Android #14537

Closed
duhseekoh opened this issue Jun 15, 2017 · 13 comments
Closed

[Android] AppState 'inactive' not triggered on Android #14537

duhseekoh opened this issue Jun 15, 2017 · 13 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@duhseekoh
Copy link

duhseekoh commented Jun 15, 2017

Description

When listening to an AppState change, inactive is never triggered on Android, only background.

Reproduction Steps

  1. Setup a change listener on AppState.
  2. Output the current app state in the listener function.
  3. Send the app to the background (go to home screen) and notice background is logged, but never inactive

Sample Code

componentDidMount() {
  AppState.addEventListener('change', this._handleAppStateChange);
}

_handleAppStateChange(currentAppState) {
  console.log(currentAppState); // never outputs 'inactive' on android
}

Additional Information

  • React Native version: 0.43.3
  • Platform: Android
  • Development Operating System: macOS
  • Testing on: Android Simulator with a Nexus 5 with Nougat
@duhseekoh duhseekoh changed the title AppState 'inactive' not triggered on Android [Android] AppState 'inactive' not triggered on Android Jun 15, 2017
@Geor23
Copy link

Geor23 commented Jul 4, 2017

+1 RN 0.44.0, 0.45.1

@Memerto
Copy link

Memerto commented Jul 12, 2017

+1

@gsavchenko
Copy link

gsavchenko commented Jul 18, 2017

+1 RN 0.45.1

@ragamufin
Copy link

+1

@sijangurung
Copy link

+1 RN 0.42.0

@JLWalsh
Copy link

JLWalsh commented Aug 8, 2017

+1. The inactive state is not sent when receiving a phone call aswell.

Edit: Have a look at AppStateModule. It seems that there are only three states possible: uninitalized, foreground and background. Correct me if I'm wrong, but I don't think that Android has the inactive state, so that would explain why it was not implemented on Android. It would be a good thing to mention in the docs.

@martin-rueegg
Copy link

@JLWalsh, according to https://stackoverflow.com/a/41009169/3102305, there seems to be an inactive (onPause) event/state.

Hope that helps.

Our issue is, that we want to re-render the main component for privacy reasons as the screenshot of the app that is used in the task list should only show a "covered" version, not the apps last screen.

@martin-rueegg
Copy link

just for reference: [AppState] App state never becomes "inactive"

@stale
Copy link

stale bot commented Nov 10, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 10, 2017
@stale stale bot closed this as completed Nov 17, 2017
@martin-rueegg
Copy link

I'm not aware that the issue is solved. It would be required to take action when the app goes into background, e.g. covering the app's screen for privacy reasons, so that the system's screenshot in the app-switch does not show the content of the app, but it's lock screen.

@ghost
Copy link

ghost commented Apr 16, 2018

Did you find a solution for the described case? @martin-rueegg ?

We need it for the same scenario. Rendering a view before the Snapshot for Task Switcher is made (Android). On iOS it works just fine.

@YKSing
Copy link

YKSing commented Apr 23, 2018

I also discover that when detecting NFC, it will also trigger background and then active.

@alexlevy0
Copy link

+1

@facebook facebook locked as resolved and limited conversation to collaborators Nov 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

10 participants